gatsby --version > -bash: gatsby: command not foun

2020-03-19 02:11发布

问题:

I use mac and I installed gatsby-cli by:

npm install --global gatsby-cli

and 'npm root -g' command prints:

/usr/local/lib/node_modules/npm/lib/node_modules

npm successfully installed gatsby but, I cannot run gatsby command (gatsby --version, gatsby --help) Whenever I type and run "gatsby --version" it prints:

-bash: gatsby: command not found

Is there any way I can fix this problem??

回答1:

you have to update your config. You may have to follow few steps

Set Config

remove existing config

npm config delete prefix 

set new config

npm config set prefix /usr/local

Install gatsby

npm i -g gatsby-cli

now check version

gatsby --version


回答2:

I came across the same issue. npx gatsby -v worked. Hope this helps somebody. Reference: https://github.com/gatsbyjs/gatsby/issues/15276#issuecomment-507340096



标签: npm gatsby