How come npm install doesn't work on git bash
In our case, the solution was simply to close the Git bash window and re-open it.
In git bash type ...
which npm
This will tell you where npm is installed.
Now, I'm assuming this will give you nothing since it seems npm is not on your system PATH variable. The PATH variable defines where Windows looks for commands.
Go into your control panel and click system advanced settings and add the directory containing npm to your path.
If you dont know where it is then open a normal windows console and type ...
where npm
This will show you where it is so you can add it to your path.
Then close your git bash terminal and reopen it and npm should work.
PS if you want to check the PATH variable inside git bash, make sure the correct npm folder is on the PATH then just type ...
echo $PATH
PPS Another tip - you can tweak the PATH for git bash only via your .bashrc OR .bash_profile files.
If you are on Windows, try this: In CMD, go to folder
C:\Program Files or (x86)\nodejs\
Then try the following
C:\Program Files\nodejs>set path=%PATH%;%CD%
C:\Program Files\nodejs>setx path "%PATH%"
It works for me!
If you installed git bash first and then node.js, uninstall gitbash and keep node.js. And then re-install git bash again.
npm --version
node --version
check version using this command
The default terminal emulator installed by git is named Mintty. To run npm
with Mintty, you need to add the path to an environment variable.
Add the following line to your ~\.bash_profile
file. If it does not exist, create it.
PATH="/usr/local/share/npm/bin:/usr/local/bin:/usr/local/sbin:~/bin:$PATH"
When Mintty starts up it will read .bash_profile
. You should now be able to run npm
from Mintty.
These other questions might be helpful also.
https://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path https://askubuntu.com/questions/58814/how-do-i-add-environment-variables