0

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

0

2 Answers 2

9
+100

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

6
  • Globally, so that I can run it with just gulp. npm list -g returns hundreds of modules located at /Users/{user}/.nvm/versions/node/v11.4.0/lib. How would I fix a $PATH issue?
    – Sean
    Mar 7, 2019 at 13:49
  • NVM is a game changer here. I just edited my response accordingly. It results in gulp being installed under ~/.nvm, but the shell not being able to find it. Does running source ~/.nvm/nvm.sh on a shell fix the issue temporarily? If so, just add this line to your rcfile to make it permanent (and restart each open shell).
    – Pierre
    Mar 7, 2019 at 15:29
  • It did fix it temporarily. I've found a .bash_profile file—does that sound right? It already has something similar in it: export NVM_DIR="$HOME/.nvm" then [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh". Will adding what you suggest conflict with this?
    – Sean
    Mar 7, 2019 at 15:52
  • If it fixes the issue temporarily, that means that the command is not executed properly. Most likely your .bash_profile is not executed when opening a new terminal window -- .bash_profile is usually executed only for login shells. I would suggest adding these lines too .bashrc as well (creating it if it does not exist), or executing your .bash_profile from there: source ~/.bash_profile. Cf: apple.stackexchange.com/questions/51036/…
    – Pierre
    Mar 7, 2019 at 16:00
  • I created .bashrc with the line you suggested and everything seems to be working as expected. Really appreciate your help! You're a lifesaver.
    – Sean
    Mar 7, 2019 at 16:06
4

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

1
  • npx gulp -v works, and returns CLI version 2.0.1 and Local version 4.0.0. How can I fix it so I don't have to use npx?
    – Sean
    Mar 4, 2019 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.