nvm-windows: Clean install of nvm 1.1.5, node 8.10.0 - npm not working

C:\Users\me> nvm install 8.10.0
Downloading node.js version 8.10.0 (64-bit)...
Complete
Creating C:\Users\me\AppData\Roaming\nvm\temp

Downloading npm version 5.6.0... Complete
Installing npm v5.6.0...

Installation complete. If you want to use this version, type

nvm use 8.10.0

C:\Users\me> nvm use 8.10.0
Now using node v8.10.0 (64-bit)

C:\Users\me> npm --version
module.js:549
    throw err;
    ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3
module.js:549
    throw err;
    ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3

The directory C:\Users\me\AppData\Roaming\nvm\v8.10.0\node_modules exists, but is empty.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 20
  • Comments: 28 (2 by maintainers)

Most upvoted comments

Still having the same problem. Still haven’t seen 1.1.8 after one year @coreybutler

I had de same issue (empty node_modules dir) and disabling antivirus solved the problem (using nvm 1.1.7)

There are no spaces (or other odd characters) in nvm root.

Upgrade to v1.1.7, which resolves #373 (issues with npm for Node 10.x.x+). The issue with spaces in the path has been resolved in master (via PR #355) and is scheduled for release in 1.1.8. If you need the functionality right now, you can build from source. I’ll get 1.1.8 out as soon as I can, but there are a few other fixes still being merged in.

Closing since the aforementioned issues/resolutions should resolve this one.

I have the exact same issue also with nvm 1.1.6 and installing node 10.6.0 (or any other node version).

If I navigate to <nvm-root>/v10.6.0/node_modules the folder is just empty. This fits to the error message when trying to run npm.

 Directory of C:\Users\flawi\AppData\Roaming\nvm\v10.6.0\node_modules

09.07.2018  18:22    <DIR>          .
09.07.2018  18:22    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  220.739.076.096 bytes free

If I observe the installation process after nvm install 10.6.0, I can see how npm is downloaded and extracted in C:\Users\flawi\AppData\Roaming\nvm\temp (I see the npm-v6.1.0.zip and the extracted folders). However, after the installation nothing is moved to <nvm-root>/v10.6.0/node_modules.

For completeness here is my settings.txt:

root: C:\Users\flawi\AppData\Roaming\nvm
path: C:\Program Files\nodejs

By the way, I have same issue also with nvm versions 1.1.5 and 1.1.4 (also if I use paths without spaces).

Mitigation

If you copy npm-v6.1.0.zip from <nvm-root>/v10.6.0/temp after the download is complete and extract it yourself into <nvm-root>/v10.6.0/node_modules/npm everything is working fine.

Hi

For anyone that would be have this problem. I can say that, in my case i discover that problem is happening when i’m running the installer from a different partition to windows was installed.

So when i reinstall using nvm-setup.exe from C: partition, all is installed an npm is finded without problems!!, no need to modify enviroment variables in my win10.

I know that this looks crazy, but i think that this can be usefull to developers resolve this issue, or anyone need help for this now.

bye.

I’ve just gone and had a look at the source code.

// sometimes Windows can take some time to enable access to large amounts of files after unzip, use exponential backoff to wait until it is ready

If that’s true, it may be that the AV is massively slowing it down by scanning every single extracted file (of which there are ~4400). You don’t seem to do anything when your retry loop gives up, which would explain why the failure is completely silent.

I reckon you either need to change how you wait for them to be “ready”, or you need to extract them directly to the right place.

@filipemerker

(2019-09-06) I am actively working on new Github actions to build releases. There are several great contributions in master (which contains the to-be-released 1.1.8 version), but I’ve always had to build these by hand… and as many of you have noticed, my time has been extremely limited for quite awhile. The time consuming part is preparing the NSIS build, but once that is automated, it should be significantly easier for people to contribute changes and actually see them released.

Of course I still don’t think 1.1.8 will fix this (unless there have been other changes not mentioned here). There’s something about the way it tries to install npm that anti-virus really doesn’t like, and a blanket “disable AV” is not something that everyone wants to do or even can do.

For McAfee Endpoint Security, it is “On-Access Scan” that blocks it. However, there’s never anything in its logs when it does (or they’re only accessible to my network admins).