-bash: gulp: 在 Mac 中找不到命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35884163/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 14:21:39  来源:igfitidea点击:

-bash: gulp: command not found in Mac

macosbashnpmgulp

提问by ?_?

I try install gulp in mac like this :

我尝试像这样在 mac 中安装 gulp:

Is-iMac:~ itop$ npm root
/Users/itop/node_modules
Is-iMac:~ itop$ npm config set prefix /usr/local
Is-iMac:~ itop$ npm root -g
/usr/local/lib/node_modules
Is-iMac:~ itop$ sudo npm install -g gulp

After Install I see this error In terminal:

安装后,我在终端中看到此错误:

npm WARN deprecated [email protected]: 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 [email protected]: lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^4.0.0.
npm WARN deprecated [email protected]: 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 ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "gulp"
npm ERR! node v5.6.0
npm ERR! npm  v3.8.0
npm ERR! path /usr/local/bin/gulp
npm ERR! code EEXIST

npm ERR! Refusing to delete /usr/local/bin/gulp: ../lib/node_modules/gulp-cli/bin/gulp.js symlink target is not controlled by npm /usr/local
npm ERR! File exists: /usr/local/bin/gulp
npm ERR! Move it away, and try again.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/it/npm-debug.log

Now when i type gulpfor start/run in terminal i see this error:

现在,当我gulp在终端中输入start/run 时,我看到此错误:

-bash: gulp: command not found

EDIT:I try with this comment By archie-voyageur:

编辑:我尝试使用archie-voyageur 的这个评论:

npm install --global gulp-cli

And See this error:

并看到这个错误:

/usr/local/bin/gulp -> /usr/local/lib/node_modules/gulp-cli/bin/gulp.js
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--global" "gulp-cli"
npm ERR! node v5.6.0
npm ERR! npm  v3.8.0
npm ERR! path /usr/local/share/man/man1/gulp.1
npm ERR! code EEXIST

npm ERR! Refusing to delete /usr/local/share/man/man1/gulp.1: ../../../lib/node_modules/gulp/gulp.1 symlink target is not controlled by npm /usr/local
npm ERR! File exists: /usr/local/share/man/man1/gulp.1
npm ERR! Move it away, and try again.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/itop/npm-debug.log

How do fix this?

如何解决这个问题?

回答by binz

Just came across this issue myself and managed to solve the issue with:

我自己刚刚遇到了这个问题并设法解决了这个问题:

$ npm uninstall --global gulp gulp-cli
$ rm /usr/local/share/man/man1/gulp.1
$ npm install --global gulp-cli

回答by VPC

go to

cd /usr/local/bin
ls -las

if gulp is present delete that directory. (sudo rm -rf gulp) reinstall gulp-cli

如果存在 gulp,请删除该目录。(sudo rm -rf gulp) 重新安装 gulp-cli

===================================================================

================================================== ==================

if it is not working uninstall node, npm completely and try again

如果它不起作用卸载节点,请完全 npm 并重试

follow this link for step by step guide

按照此链接获取分步指南

node and npm uninstall step by step

node 和 npm 一步一步卸载

回答by franmartosr

I think you have gulp installed in your system, or at least you have some files related to gulp. Just do npm uninstall --global gulp gulp-cliand then try to install it again with npm install --global gulp-cli. If this doesn't work, I don't know what is happening on your system.

我认为您的系统中安装了 gulp,或者至少您有一些与 gulp 相关的文件。只需执行npm uninstall --global gulp gulp-cli,然后尝试使用npm install --global gulp-cli. 如果这不起作用,我不知道您的系统上发生了什么。

回答by Omer Levi Hevroni

For me it worked only when I installed gulpusing npminstead of yarn. Very weird..

对我来说,它仅在我安装gulpusingnpm而不是yarn. 很奇怪..

回答by Avery Carter

After pulling my hair out trying all of these, I ended up being able to install stupid gulp by doing

在尝试了所有这些之后,我终于能够通过执行以下操作来安装愚蠢的 gulp

npm uninstall --global gulp gulp-cli

yarn global add gulp