运行任何gatsby命令都会显示“ -bash:gatsby:找不到命令”

时间:2019-06-07 10:26:02

标签: gatsby

我正在尝试克隆一个用gatsby构建的站点,并在我的笔记本电脑中本地运行它。 但是,键入任何gatsby命令都会在命令提示符下发出以下警报:

-bash:gatsby:找不到命令

我尝试手动卸载并重新安装gatsby,而不使用GitHub Repository。但是它仍然没有解决。

对于本地站点,我遵循了this site中的以下说明:

  1. git clone git@github.com:PlatformOfTrust/pot-websites.git
  2. cd developer-site or marketing-site
  3. npm install
  4. npm install --global gatsby-cli
  5. gatsby develop -o -p 8000

在执行gatsby develop -o -p 8000时,该站点应在本地运行:localhost:8000。但是终端只是说

-bash:gatsby:找不到命令

这是终端在执行命令序列时的输出:

Last login: Fri Jun  7 15:15:07 on ttys000
TILMACLT17-2:~ naziahasan$ cd Documents/GitHub/
TILMACLT17-2:GitHub naziahasan$ ls -a
.       ..      .DS_Store   docs
TILMACLT17-2:GitHub naziahasan$ git clone git@github.com:PlatformOfTrust/pot-websites.git
Cloning into 'pot-websites'...
remote: Enumerating objects: 418, done.
remote: Counting objects: 100% (418/418), done.
remote: Compressing objects: 100% (256/256), done.
remote: Total 3958 (delta 267), reused 279 (delta 158), pack-reused 3540
Receiving objects: 100% (3958/3958), 39.25 MiB | 250.00 KiB/s, done.
Resolving deltas: 100% (2384/2384), done.
TILMACLT17-2:GitHub naziahasan$ cd pot-websites/developers-site/
TILMACLT17-2:developers-site naziahasan$ npm install

> fsevents@1.2.7 install /Users/naziahasan/Documents/GitHub/pot-websites/developers-site/node_modules/fsevents
> node install

node-pre-gyp WARN Using request for node-pre-gyp https download 
[fsevents] Success: "/Users/naziahasan/Documents/GitHub/pot-websites/developers-site/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" is installed via remote

> sharp@0.21.3 install /Users/naziahasan/Documents/GitHub/pot-websites/developers-site/node_modules/gatsby-plugin-sharp/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Using cached /Users/naziahasan/.npm/_libvips/libvips-8.7.0-darwin-x64.tar.gz

> sharp@0.21.1 install /Users/naziahasan/Documents/GitHub/pot-websites/developers-site/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Using cached /Users/naziahasan/.npm/_libvips/libvips-8.7.0-darwin-x64.tar.gz

> gatsby-telemetry@1.0.2 postinstall /Users/naziahasan/Documents/GitHub/pot-websites/developers-site/node_modules/gatsby-telemetry
> node src/postinstall.js


> gatsby-telemetry@1.0.4 postinstall /Users/naziahasan/Documents/GitHub/pot-websites/developers-site/node_modules/gatsby/node_modules/gatsby-telemetry
> node src/postinstall.js


> cwebp-bin@5.0.0 postinstall /Users/naziahasan/Documents/GitHub/pot-websites/developers-site/node_modules/cwebp-bin
> node lib/install.js

  ✔ cwebp pre-build test passed successfully

> mozjpeg@6.0.1 postinstall /Users/naziahasan/Documents/GitHub/pot-websites/developers-site/node_modules/mozjpeg
> node lib/install.js

  ✔ mozjpeg pre-build test passed successfully

> pngquant-bin@5.0.2 postinstall /Users/naziahasan/Documents/GitHub/pot-websites/developers-site/node_modules/pngquant-bin
> node lib/install.js

  ✔ pngquant pre-build test passed successfully

> styled-components@4.2.0 postinstall /Users/naziahasan/Documents/GitHub/pot-websites/developers-site/node_modules/styled-components
> node ./scripts/postinstall.js || exit 0

Use styled-components at work? Consider supporting our development efforts at https://opencollective.com/styled-components
added 1926 packages from 1048 contributors in 99.154s
TILMACLT17-2:developers-site naziahasan$ npm install --global gatsby-cli
/Users/naziahasan/.npm-global/bin/gatsby -> /Users/naziahasan/.npm-global/lib/node_modules/gatsby-cli/lib/index.js
+ gatsby-cli@2.6.5
updated 1 package in 15.567s
TILMACLT17-2:developers-site naziahasan$ gatsby develop -o -p 8000
-bash: gatsby: command not found
TILMACLT17-2:developers-site nazia

以下是我尝试卸载并重新安装gatsby时来自终端的输出:

TILMACLT17-2:~ naziahasan$ gatsby --version
-bash: gatsby: command not found
TILMACLT17-2:~ naziahasan$ npm uninstall -g gatsby-cli
removed 296 packages in 1.618s
TILMACLT17-2:~ naziahasan$ npm install -g gatsby-cli
/Users/naziahasan/.npm-global/bin/gatsby -> /Users/naziahasan/.npm-global/lib/node_modules/gatsby-cli/lib/index.js

> core-js@2.6.9 postinstall /Users/naziahasan/.npm-global/lib/node_modules/gatsby-cli/node_modules/core-js
> node scripts/postinstall || echo "ignore"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> gatsby-telemetry@1.0.11 postinstall /Users/naziahasan/.npm-global/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry
> node src/postinstall.js

+ gatsby-cli@2.6.5
added 296 packages from 172 contributors in 14.686s
TILMACLT17-2:~ naziahasan$ gatsby --version
-bash: gatsby: command not found
TILMACLT17-2:~ naziahasan$ 

我想知道是否需要在.npm-global / bin /下的gatsby配置中进行更改,或者将gatsby的位置添加到Path变量中。

一些帮助将不胜感激!谢谢!

1 个答案:

答案 0 :(得分:0)

尝试以管理员身份全局安装 gatsby-cli

sudo npm i -g gatsby-cli