【问题标题】:-bash: gulp: command not found in Mac-bash: gulp: 在 Mac 中找不到命令
【发布时间】:2016-06-23 09:20:39
【问题描述】:

我尝试像这样在 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

安装后我在终端看到这个错误:

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

现在当我在终端输入gulp 启动/运行时,我看到了这个错误:

-bash: gulp: command not found

编辑: 我试试这个评论 By archie-voyageur:

npm install --global gulp-cli

看到这个错误:

/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

如何解决这个问题?

【问题讨论】:

  • @ArchieVoyageur:谢谢我试试这个请看我的编辑。
  • 我不确定我是否理解 File exists, Move it away, and try again. 的不清楚之处 ....

标签: macos bash npm gulp


【解决方案1】:

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

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

【讨论】:

  • 2017 年 11 月为我工作 - OSX Sierra。
【解决方案2】:

转到

cd /usr/local/bin
ls -las

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

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

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

点击此链接获取分步指南

node and npm uninstall step by step

【讨论】:

    【解决方案3】:

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

    【讨论】:

    • 您唯一能做的就是从您的系统中卸载 Node 并重新从头开始安装它。但我对此不抱太大希望,因为我不知道是什么导致了您的问题。
    【解决方案4】:

    在尝试了所有这些之后,我最终能够安装愚蠢的 gulp

    npm uninstall --global gulp gulp-cli
    
    yarn global add gulp
    

    【讨论】:

      【解决方案5】:

      对我来说,只有当我使用 npm 而不是 yarn 安装 gulp 时它才有效。很奇怪..

      【讨论】:

        猜你喜欢
        • 2016-06-05
        • 2012-10-03
        • 1970-01-01
        • 1970-01-01
        • 2015-08-08
        • 2014-10-10
        • 2019-09-04
        • 2013-10-21
        相关资源
        最近更新 更多