gatsby --version> -bash:gatsby:找不到命令

gatsby --version> -bash:gatsby:找不到命令

问题描述:

我使用Mac,并通过以下方式安装了gatsby-cli:

I use mac and I installed gatsby-cli by:

npm install --global gatsby-cli

和'npm root -g'命令打印:

and 'npm root -g' command prints:

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

npm成功安装了gatsby,但是, 我无法运行gatsby命令(gatsby --version,gatsby --help) 每当我键入并运行"gatsby --version"时,都会打印:

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??

您必须更新配置.您可能需要遵循几个步骤

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

设置配置

删除现有配置

npm config delete prefix 

设置新配置

npm config set prefix /usr/local

安装盖茨比

npm i -g gatsby-cli

现在检查版本

gatsby --version