全局安装gulp后,找不到命令

时间:2016-02-26 06:47:18

标签: macos bash path npm gulp

在一次明显成功的全球安装之后,我仍然得到"命令未找到"对于诸如gulp -v之类的gulp命令。我尝试在$ PATH中加入一些东西(具体如下),但它没有帮助。我怀疑我需要确定全局安装gulp的位置,以便我可以将其添加到$ PATH。任何帮助将不胜感激!

OSX 10.9.5

我在终端的输入在下面以粗体显示,灰色框是响应的终端输出

npm install -g gulp

npm WARN deprecated graceful-fs@3.0.8: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.
npm WARN deprecated lodash@1.0.2: lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^4.0.0.
npm WARN deprecated graceful-fs@1.2.3: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs@^4.0.0 as soon as possible.
/Users/mh/.node/bin/gulp -> /Users/mh/.node/lib/node_modules/gulp/bin/gulp.js
/Users/mh/.node/lib
└── gulp@3.9.1

gulp -v

-bash: gulp: command not found

我尝试将gulp安装结束时显示的三条路径添加到/etc/paths(请参阅下面的最后三行)。当我echo $PATHgulp -v仍然失败时,会显示三条路径。

/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/usr/local/git/bin
/Users/mh/.node/lib
/Users/mh/.node/lib/node_modules/gulp/bin/
/Users/mh/.node/bin/gulp

gulp -v

-bash: gulp: command not found

1 个答案:

答案 0 :(得分:0)

安装gulp后,创建了从/Users/mh/.node/bin/gulp/Users/mh/.node/lib/node_modules/gulp/bin/gulp.js的符号链接。

但是,您不应该将符号链接本身添加到$PATH。您必须添加它所在的目录:

export PATH="$PATH:/Users/mh/.node/bin"

这应该可以解决问题。