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

瘦欲@ 提交于 2019-12-24 23:23:20

问题


Whenever I run gulp, I get the following error:

/usr/local/bin/gulp: No such file or directory

I've followed the answers to several related questions on SO, but none have solved my issue. I've been using gulp without issue for months, but managed to screw it up somehow.

I've remove gulp and gulp-cli (using npm) both locally and globally.

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

Any help is appreciated.

EDIT:

Installing gulp globally npm install -g gulp doesn't fix anything.


回答1:


Do you want to install gulp locally or globally?

Locally

npm install --save-dev gulp gulp-cli should do the trick. You can then run it using:

  • ./node_modules/.bin/gulp
  • npm run gulp if you add gulp to the scripts section of package.json.

Globally

Most likely you have a $PATH issue. Did you check where your global libraries are installed by NPM?

npm list -g

Does installing any other global library work, or is it specific to Gulp?

-- Edit --

If you are using NVM, you should add the NVM setup to your rcfile (that is, ~/.bashrc, ~/.zshrc, ~/.profile or similar). You can do so by appending these lines to your 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).




回答2:


Try npx gulp so that npm using the gulp version that is installed in your dependencies.



来源:https://stackoverflow.com/questions/54986239/gulp-usr-local-bin-gulp-no-such-file-or-directory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!