CLI references wrong npm version
command-line-interface, node.js, npm, windows
Solution
After opening this issue on joyent/node, this reply suggests using the Node.js command prompt as a temporary workaround.
Preparation:
- Remove `C:\Program Files\nodejs` from any environment variables
- Add a environment variable called `NODE_PATH` with this value: `%AppData%\npm\node_modules`
Check your `.npmrc` file (Windows: `C:\Users\[User]\.npmrc`)
If the value for `prefix` is `c:\Program Files\nodejs`, add `prefix = c:\Users\[User]\AppData\Roaming\npm` to the user config area (at the top of the file)
After this:
- Start Menu > All Programs > Node.js > Node.js command prompt
- `npm -v`: 1.4.14
- `npm install -g npm`
- `npm -v`: 1.4.21
Problem
- Installed node.js v0.10.29 with .msi (includes npm v1.4.14) - `npm install -g npm` (updating npm to v1.4.20) - `npm -v`: v1.4.14 (located in `c:\Program Files\nodejs\node_modules\npm`) - npm v1.4.20 is located in `c:\Users\User\AppData\Roaming\npm\node_modules\npm` `echo %path`: C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\nodejs;C:\Ruby200-x64\bin;C:\python27 - Removing the bold part leaves me with `sh.exe": npm: command not found` - Adding `%AppData%\npm\node_modules` doesn't fix it 6. Adding `NODE_PATH` to system wide environment variables with `%AppData\npm\node_modules` is not helping The problem is essentially that it refuses to recognize the global npm installation in `%AppData%\npm\node_modules` even when I remove `C:\Program Files\nodejs` from the path and replace it with `%AppData%\npm\node_modules`. What am I doing wrong? How do I fix this?