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

With 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!