简体   繁体   English

Gulp: /usr/local/bin/gulp: 没有那个文件或目录

[英]Gulp: /usr/local/bin/gulp: No such file or directory

Whenever I run gulp, I get the following error:每当我运行 gulp 时,都会出现以下错误:

/usr/local/bin/gulp: No such file or directory /usr/local/bin/gulp: 没有那个文件或目录

I've followed the answers to several related questions on SO, but none have solved my issue.我遵循了关于 SO 的几个相关问题的答案,但没有一个解决了我的问题。 I've been using gulp without issue for months, but managed to screw it up somehow.几个月来我一直在使用 gulp 没有问题,但设法以某种方式把它搞砸了。

I've removed gulp and gulp-cli (using npm) both locally and globally.我已经在本地和全局删除了 gulp 和 gulp-cli(使用 npm)。

After running the following:运行以下命令后:

npm install -g gulp-cli
npm install --save-dev gulp

Any command using gulp, even gulp -v returns the error mentioned above.任何使用 gulp 的命令,甚至gulp -v返回上述错误。 There are no errors during the installation.安装过程中没有错误。

I've confirmed there is nothing at /usr/local/bin/gulp , but shouldn't reinstalling things recreate whatever files are supposed to be there?我已经确认/usr/local/bin/gulp没有任何内容,但不应该重新安装东西重新创建应该在那里的任何文件?

Any help is appreciated.任何帮助表示赞赏。

EDIT:编辑:

Installing gulp globally npm install -g gulp doesn't fix anything.全局安装 gulp npm install -g gulp不能解决任何问题。

Do you want to install gulp locally or globally?你想在本地还是全局安装 gulp?

Locally本地

npm install --save-dev gulp gulp-cli should do the trick. npm install --save-dev gulp gulp-cli应该可以解决问题。 You can then run it using:然后,您可以使用以下命令运行它:

  • ./node_modules/.bin/gulp
  • npm run gulp if you add gulp to the scripts section of package.json .如果将 gulp 添加到package.json的 scripts 部分,则npm run gulp

Globally全球范围内

Most likely you have a $PATH issue.很可能您有$PATH问题。 Did you check where your global libraries are installed by NPM?您是否检查过 NPM 安装了全局库的位置?

npm list -g

Does installing any other global library work, or is it specific to Gulp?安装任何其他全局库是否有效,还是特定于 Gulp?

-- Edit -- - 编辑 -

If you are using NVM, you should add the NVM setup to your rcfile (that is, ~/.bashrc , ~/.zshrc , ~/.profile or similar).如果您使用 NVM,您应该将 NVM 设置添加到您的 rcfile(即~/.bashrc~/.zshrc~/.profile或类似文件)。 You can do so by appending these lines to your rcfile.您可以通过将这些行附加到您的 rcfile 来实现。

[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh

This will load NVM and update your PATH so that your shell is able to find gulp (or any other globally-installed program by npm or yarn ).这将加载 NVM 并更新您的PATH以便您的 shell 能够找到gulp (或任何其他由npmyarn全局安装的程序)。

尝试npx gulp以便 npm 使用安装在依赖项中的 gulp 版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM