nvm-windows: 'Cannot find module' when calling NPM
Everything seems properly installed, executing nvm list
gives…
0.12.3
* 0.10.38 (Currently using ?-bit executable)
However when I try to run npm
, error pops out…
module.js:340
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli. js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:935:3
It is right about it, there is no npm module installed in node_modules directory for either version of node installed.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 39 (9 by maintainers)
Unfortunately, I don’t have a Win 2012 server to test on right now.
The 100% manual way to do this:
C:\Program Files\nodejs
(or wherever you setup the symlink).node_modules
. Download the appropriate npm release. Extract the contents. At this point you should simply have a folder callednpm
within thenode_modules
directory.C:\Program Files\nodejs
… same level as thenode_modules
,node.exe
, andnode64.exe
). Create thenpm
and npm.cmd` files. The code is available in this gist.If you’re seeing the
(Currently using ?-bit executable)
, there are two solutions. First, you can build from source (the master branch has a fix for this). The alternative is to install each version of node (i.e. 32 bit and 64-bit) separately. In @FredyC’s example, you could do bothnvm install 0.10.38 32
andnvm install 0.10.38 64
. Alternatively, you can find the node executable, copy it, and paste it as either node32.exe or node64.exe. Yes, it’s an ugly hack.NVM isn’t recognizing the appropriate version of the node executable due to a missing case statement in the code. The aforementioned hack essentially resets the state so it works correctly. After that, npm should work properly. If not, let me know which version of Windows you’re running and whether you had anything installed prior to the NVM install (i.e. a prior version of node, io.js, etc).
@PlatinumEagle I was in a similar situation…on a Dell computer with McAfee pre-installed. Disabling McAfee’s “Real-Time Scanning”, uninstalling NVM for Windows (NVM4W), and re-installing NVM4W from a Command Prompt that was running as an Administrator fixed the problem. I was able to re-enable McAfee with no additional issues.
Exact same symptoms, root cause was McAfee interfering (came pre-installed on my Dell) with the installation. Disabled real time scanning and reinstalled nvm-windows. Then everything worked properly.
Note: There is a note about McAfee interference here in the readme for this project (https://github.com/coreybutler/nvm-windows#antivirus), but the referenced symptoms are not the same.
I think I’m running into the same issue
My Environment
I’m using NVM4W version:
I’ve tried using cmd and the built in win command line interface, both with admin privileges and without, with the same result.
Update 10/4
I confirmed that my
node_modules
also ended up empty upon installation. Which is kind of strange as nothing suggests otherwise. Output for installing v9.11.2:And the same output as before my update when I try to run
npm
.So I installed a copy of
v9.11.2
outside of nvm using the official installer. Copied thenpm
files from that installation’s npm_modules to my nvm installation, uninstalled the standalone version, and lo and behold, my nvm installation isn’t complaining anymore when I runnpm
.I’ve been running all commands and installations using admin privileges so that shouldn’t be the issue here, I’m not a regular windows user though so I might have missed something or gotten something wrong, who knows …
It would be nice if NVM could detect this failure, provide an appropriate error message, and roll back the install
Do you see the
(Currently using ?-bit executable)
or do you see(Currently using 64-bit executable)
when you do annvm list
? It’s a critical answer because the code can prevent the npm installation.I just had the same problem and “solved” it by running NVM as administrator.