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!
-
-
Save LeandroGabrielAyala/f8ec289e5acf66434b052eb516941851 to your computer and use it in GitHub Desktop.
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!
Try npm link gulp
thank you! it helped!
Leonardo, i have passed 2 days for this and you just saved my mind .I love you man , thank you.
life saver!
I found this solution was also shared on StackOverflow and this blog post. Worked for me as well.
Try npm link gulp
This did it for me. Thank you.
Try npm link gulp
Work for me to ! thank's
Thanks a lot for this answer
You´re a livesaver. Thanks a lot!
This didn't work for me, but I found another solution that did.
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
PATH="$HOME/.npm/bin:$PATH"
PATH="./node_modules/.bin:$PATH"
I just added the lines that didn't exist in my ~/.zshrc file.
I have created a directory for global installations in the $HOME directory instead of using sudo for the installations in the /usr. Below are the steps I followed and installed gulp but seeing command not found in the VS code project. Can someone please let me know what is the issue here?
`Make a directory for global installations in the $HOME directory,
mkdir ~/.npm-global
Configure npm to use the new directory path,
npm config set prefix '~/.npm-global'
Open or create a /.zsh_profile file and add this line,/.npm-global/bin:$PATH
export PATH=
Back on the command line, update your system variables,
source ~/.zsh_profile`
I have created a directory for global installations in the $HOME directory instead of using sudo for the installations in the /usr. Below are the steps I followed and installed gulp but seeing command not found in the VS code project. Can someone please let me know what is the issue here? `Make a directory for global installations in the $HOME directory, mkdir ~/.npm-global
Configure npm to use the new directory path, npm config set prefix '~/.npm-global'
Open or create a
/.zsh_profile file and add this line, export PATH=/.npm-global/bin:$PATHBack on the command line, update your system variables, source ~/.zsh_profile`
I resolved it. I was updating the incorrect file - the path should be updated in ~/.zshrc file but not ~/.zsh_profile
Thank you my brother!)
I have been having exactly the same issue for last couple of days. After going in circles with changing path and other stuff suggested, nothing worked. Then I tried this approach and worked flawlessly, so a huge thank you.