맥북 M1 Monterey에서 Gatsby 프로젝트 생성하기(Gatsby Command Not Found 해결)

하스레·2022년 4월 13일
0

터미널에서 gatsby-cli 를 설치하고 이를 사용해서 프로젝트를 생성한 후, 다음과 같이 프로젝트에 들어가 로컬 서버를 실행하려 했으나 gatsby command not found 라는 오류가 났다.

(base)hssarah@ihansleBook ~ % cd portfolio-website
(base)hssarah@ihansleBook portfolio-website % gatsby develop
zsh: command not found: gatsby

이를 해결하기 위해 다음과 같이 진행해주었다.
1. npm path prefix를 제거하고 '/usr/local'로 세팅해준다.

npm config delete prefix
npm config set /usr/local
  1. sudo를 붙여서 gatsby-cli를 global로 다운받는다.
sudo npm install -g gatsby-cli
  1. 잘 다운받아졌는지 버젼 확인!
gatsby -v
  1. gatsby 프로젝트를 생성한다.
gatsby new portfolio-website
  1. 그럼 cd로 프로젝트 들어가서 gatsby develop으로 로컬 서버 실행하라고 한다.
    그대로 따라해주면 드디어 됐다!
(base)hssarah@ihansleBook Projects % cd portfolio-website
(base)hssarah@ihansleBook portfolio-website % gatsby develop
success compile gatsby files - 0.623s
success load gatsby config - 0.015s
success load plugins - 19.129s
success onPreInit - 0.007s
success initialize cache - 0.098s
success copy gatsby files - 0.055s
success Compiling Gatsby Functions - 0.107s
success onPreBootstrap - 0.114s
success createSchemaCustomization - 0.023s
success Checking for changed pages - 0.001s
success source and transform nodes - 0.076s
success building schema - 0.149s
success createPages - 0.007s
success createPagesStatefully - 0.204s
info Total nodes: 44, SitePage nodes: 8 (use --verbose for breakdown)
success Checking for changed pages - 0.000s
success write out redirect data - 0.001s
success Build manifest and related icons - 0.120s
success onPostBootstrap - 0.123s
info bootstrap finished - 22.544s
success onPreExtractQueries - 0.000s
success extract queries from components - 0.899s
success write out requires - 0.004s
success run static queries - 0.044s - 2/2 45.23/s
success run page queries - 0.006s - 3/3 470.89/s
success Running gatsby-plugin-sharp.IMAGE_PROCESSING jobs - 0.155s - 3/3 19.34/s
⠀
You can now view gatsby-starter-default in the browser.
⠀
  http://localhost:8000/
⠀
View GraphiQL, an in-browser IDE, to explore your site's data and schema
⠀
  http://localhost:8000/___graphql
⠀
Note that the development build is not optimized.
To create a production build, use gatsby build

하... 진짜 며칠동안 안돼서 애먹었는데 드디어 돼서 너무 행복하다ㅠㅠ


참고 https://reactgo.com/gatsby-command-not-found/

profile
Software Developer

0개의 댓글