Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cetricokola/8bd317ff327f4e222cd54052d9312178 to your computer and use it in GitHub Desktop.
Save cetricokola/8bd317ff327f4e222cd54052d9312178 to your computer and use it in GitHub Desktop.
The "gulp" command is not found or does not work on node_modules (npm)

I recently wanted to install a new NPM module (that is Gulp). I followed the getting started guide and ran the needed command but it didn’t worked and I felt desperate… but I finally found the solution!

To give you a little context: I ran the following command for installing Gulp (a node package module) globally:

npm install -g gulp

The installation succeed but when I ran this gulp command in the command line I got a "gulp: command not found" error. It appeared that it installed “Gulp” in my local folder that is /Users/YOURUSERNAME/node_modules and not in the global NPM folder.

You can check this by running this command: npm root or npm root -g, which was returning my personal directory /Users/YOURUSERNAME/node_modules and not the expected /usr/local/lib/node_modules.

After some trial & error, I finally found the solution. You have to change the “npm config prefix” like so:

npm config set prefix /usr/local

Then when I re-ran npm root -g, I got the correct root folder: /usr/local/lib/node_modules

When I reinstalled Gulp globally (with the -g param) it finally worked and appeared that it was now correctly installed in the global NPM folder. Yeay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment