Nvm-windows: npm corrupt after nvm usage

Created on 7 Dec 2015  路  9Comments  路  Source: coreybutler/nvm-windows

When i try to use npm, from git-bash or classic cmd.exe, i get this :

module.js:340
    throw err;
    ^

Error: Cannot find module 'C:\Users\myUserName\AppData\Roaming\npm\node_modules\npm
\bin\npm-cli.js'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:289:25)
    at Function.Module.runMain (module.js:457:10)
    at startup (node.js:138:18)
    at node.js:974:3
Installer Issue

All 9 comments

Did you run nvm use x.x.x?

I can confirm this bug with nvm install 0.12.8 and nvm install 0.12.9. Both installs create an empty node_modules folder in the nodejs folder, which results in above error message.
nvm install 0.12.1 worked fine.

Check if you have a c:\program files\nodejs folder already exists, if so, delete it, reinstall nvm and try again

This solved my problems with npm and nvm

I am having the same problem as described here. A fresh install of nvm on Windows 10, followed by a restart. Then using git-bash, nvm install 4.3.0 runs perfectly. nvm use 4.3.0 results in a UAC prompt requesting permission for the symlink command to run. I allow it, and the console shows Now using node v4.3.0 (64-bit)

I then try npm and get this:

$ npm install -g serverless
module.js:328
    throw err;
    ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Function.Module.runMain (module.js:442:10)
    at startup (node.js:136:18)
    at node.js:966:3

When I look in C:\Program Files\nodejs\node_modules, it is empty. If I go to the AppData\Roaming\nvm folder, I see the folder v.4.3.0 and inside there, the node_modules folder is empty. It looks like npm was not installed correctly.

Note that I have tried what shairez suggested, to no avail.

OK I have got it to work. I watched the disk processes and saw the npm folder is downloaded to nvm\temp\ then moved. I tried a different version (4.4.2) and saw that npm was moved correctly. So I uninstalled 4.3.0, removed the version folder as instructed, and reinstalled the version. This time it worked correctly. And now npm commands work properly.

@micha-LEAP Thank you for following up and detailing the process. It's strange that it worked once.

Everything is downloaded to the temp folder to account for cancelled downloads, timeouts, etc... the point being an incomplete download would not be moved and therefore not available. It sounds like that is working for node, but not necessarily for npm. This is on my to-do list now, but I don't know when I'll get to it.

Seems that nvm returned before job is done. For example:
nvm use 5.3.0 && npm - not working.
while:
nvm use 5.3.0 && sleep 5 && npm - works

I got this error while installing node v8.15.0. Fixed it by downloading the zip file for the nodejs sit, unzipped it and replace the content in nvm\v8.15.0. It is working fine now.

Has there been any movement on this issue? I'm having this problem, too. Was careful to run nvm-windows in an Administrator window. Still, node_modules is empty. Using version 1.1.17. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Deilan picture Deilan  路  4Comments

Pomax picture Pomax  路  3Comments

David263 picture David263  路  3Comments

hsali picture hsali  路  4Comments

flpms picture flpms  路  4Comments