1

I am using git-bash/mingw32 on win7. I am trying to install npm:

$ npm install
sh: npm: command not found.

Git-bash is working normally and is installed correctly. How can I make this work?

user1592380
  • 26,587
  • 62
  • 220
  • 414

3 Answers3

8

There is a couple of reasons for this behaviour:

1) npm not installed

2) npm not in %PATH%

You can add npm to %PATH% by running cmd (win+r -> cmd) as administrator and execute:

SET PATH=%PATH%;c:\here\is\path\to\npm\dir

After that — try run npm again.

Zav
  • 641
  • 3
  • 8
1

while installing node.js when click the set path option. check system environment path.

# echo $PATH

and see if there is npm/node in it. if not, added them to the system environment.

# set PATH=%PATH%;d:/node/;

mostly reinstall node check the right option will fix this, and update dev env btw.

ρяσѕρєя K
  • 127,886
  • 50
  • 184
  • 206
vicvinc
  • 11
  • 4
0

Another possible reason (if node was installed by Visual Studio): a missing npm bash script.

There is an npm.cmd bath file in the path:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\npm.cmd

But git bash wont run .cmd files. So you need to create a bash script for npm.

Create the following file named npm in your node folder: (C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\)

#!/bin/sh
basedir=`dirname "$0"`

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  "$basedir/node"  "$basedir/node_modules/npm/bin/npm-cli.js" "$@"
  ret=$?
else 
  node  "$basedir/node_modules/npm/bin/npm-cli.js" "$@"
  ret=$?
fi
exit $ret
Gerardo Grignoli
  • 11,090
  • 6
  • 50
  • 54