nvm-windows: nvm installs node but fails to deliver npm

My Environment

  • Windows 10

I’m using NVM4W version:

  • 1.1.7

I have already…

  • read the README to be aware of npm gotchas & antivirus issues.
  • reviewed the wiki to make sure my issue hasn’t already been resolved.
  • verified I’m using an account with administrative privileges.
  • searched the issues (open and closed) to make sure this isn’t a duplicate.
  • made sure this isn’t a question about how to use NVM for Windows, since gitter is used for questions and comments.

My issue is related to (check only those which apply):

  • settings.txt
  • proxy support (Have you tried version 1.1.0+?)
  • 32 or 64 bit support (Have you tried version 1.1.3+?)
  • Character escaping (Have you tried version 1.1.6+?)
  • A standard shell environment (terminal/powershell)
  • A non-standard shell environment (Cmder, Hyper, Cygwin, git)

Expected Behavior

After running nvm install latest that node version 12.5.0 and npm version v6.9.0 is installed.

Actual Behavior

After the install command, no errors are shown:

2019-07-03_09h10_55

the following issue occurs:

2019-07-03_09h11_08

The node_modules/ folder is empty:

2019-07-03_09h32_34

Steps to reproduce the problem:

Just install a version and check what happens. don’t know exactly how this works but it seems to be something related to the new npm/cli project url change.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 33
  • Comments: 63 (5 by maintainers)

Most upvoted comments

Have the same problem. This is my attempt and works for me:

  1. download the need node version from https://nodejs.org/en/download/releases/ in zip format(or other format)
  2. Delete node_modules directory if it already exist in version drectory that located in nvm install directory(eg. C:\Users\USER_NAME\AppData\Roaming\nvm\v8.11.4).
  3. unzip the file from step 1, and copy node_modules directory to version directory infered in previous step.
  4. npm works

Have the same problem. Is there a workaround?

Why are people downloading node from the website to use with nvm, isn’t that what nvm is supposed to be for? 😉 you may as well not use nvm at all.

I had a phantom symlink nvm had created previously that it couldn’t delete because of shell permissions. I’m guessing it’s because I am using nvm in git bash shell as non-elevated user.

I deleted it in admin command prompt:

del /f c:\Program Files\nodejs

Then made new symlink to a version I had downloaded using nvm:

mklink /j "C:\Program Files\nodejs" "C:\Users\USER_NAME\AppData\Roaming\nvm\NODE_VERSION"

I haven’t tried nvm use NODE_VERSION but there’s a good chance if you delete the symlink before invoking it’ll make the link for you (I’m guessing that’s the expected behavior). Most likely would need to use something like this: https://github.com/imachug/win-sudo

Note, this comment totally works! Would be great if this is what the nvm installer did.

I can confirm this. With mcafee enabled npm is unpacked but the move fails without any error. McAfee logs show nothing at all. Disabling mcafee during installation fixes the issue. @coreybutler I know it is not a nice solution, but apparently the unzipping works so is would it be possible to directly unpack in the nodes_module/npm folder instead of unzipping to temp and moving?

I just ran

nvm uninstall NODE_VERSION

then

nvm install NODE_VERSION

and it brought npm back

Not sure why this was closed but I’m having the same issue, fresh install of Windows 10, fresh install of nvm, no Antivirus (except built-in). The official fix isn’t to bypass the very reason I’m using nvm, is it?

Have the same problem. This is my attempt and works for me:

  1. download the need node version from https://nodejs.org/en/download/releases/ in zip format(or other format)
  2. Delete node_modules directory if it already exist in version drectory that located in nvm install directory(eg. C:\Users\USER_NAME\AppData\Roaming\nvm\v8.11.4).
  3. unzip the file from step 1, and copy node_modules directory to version directory infered in previous step.
  4. npm works

Thanks @liuwenzhuang Your Comment really helped today. I have been battling with this bug for some days now

Had this happen to me today - uninstalling the version and then reinstalling it seemed to fix the issue.

Using 1.1.7, I was experiencing the same issue with NPM not being copied over from the “temp” folder, when performing a fresh install of Node.js + NPM using NVM. Since I use a company machine, I am not able able to test with McAfee Endpoint Security disabled.

However, I built NVM from “master” today, and verified it is able to correctly install from scratch without issues.

Turning off McAfee and running install from admin console fixed this for me.

Do I have to do that every time I install a new version of Node.js?

I’ve been using nvm for a couple of years and never had to do nvm on before.

I was getting a silent failure for installation of npm.

I thought it might be the Windows virus scanner, so I disabled that: image

Strangely now the failure is not silent:

$ nvm install 12.12.0
Downloading node.js version 12.12.0 (64-bit)...
Complete
Creating C:\ProgramData\nvm\temp

Downloading npm version 6.11.3... Download failed. Rolling Back.
Rollback failed. remove C:\ProgramData\nvm\temp\npm-v6.11.3.zip: The process cannot access the file because it is being used by another process.
Could not download npm for node v12.12.0.
Please visit https://github.com/npm/npm/releases/tag/v6.11.3 to download npm.
It should be extracted to C:\ProgramData\nvm\v12.12.0

Using 1.1.7, I was experiencing the same issue with NPM not being copied over from the “temp” folder, when performing a fresh install of Node.js + NPM using NVM. Since I use a company machine, I am not able able to test with McAfee Endpoint Security disabled.

However, I built NVM from “master” today, and verified it is able to correctly install from scratch without issues.

Can you share your version? I am not able to build nvm from source code 😦

Don’t think so. It didn’t change anything for me if I disabled McAfee or not. Also note that there are already two issues on that topic (a longer one and a shorter one with a script that allows you to still update npm it seems (I didn’t test it but it has 30+ thumbs up)

So I found the problem which is the realtime protection of windows image

disable it when installing node using nvm

Just found a workaround, looking at the comments related to antivirus protection.

I am on Windows 10, 64 bit, version 1909 (build 18363.1139)

  1. From Start menu open Windows Security app.
  2. Click on Virus & Threat protection tile.
  3. In the displayed interface, choose Manage settings that is under “Virus & threat protection settings”
  4. Turn off Real-time protection
  5. From start menu, find Command Prompt, right click and “Run as Administrator”
  6. run nvm install with the version you want to install. npm will properly install now. Verify with nvm use with the version, then node -v and npm -v
  7. Go back to Windows Security app and turn real-time protection back on

I’ve decided to close this issue because this is starting to touch on a number of other issues. Let’s stick to one issue per thread. Open a new issue if your problem is unaddressed.

I’ll try to summarize based on what I’ve read:

  1. npm will be installed by nvm. If you’re seeing the old path (npm/npm), you need to upgrade NVM4W to 1.1.7. If you don’t have appropriate permissions, it will fail. That’s the nature and intent of Windows and why the UAC prompts exist.
  2. Your Antivirus may prevent NVM4W from moving npm’s files from the temp directory to it’s final location. Turn it off or make an exception. See point #3.
  3. NVM4W has been submitted to every major antivirus vendor and is passing (in theory). However; antivirus software changes definitions all the time, making this difficult to keep up with. Some off-brand AV base their definitions on very outdated knowledge, the most challenging being that some block go programs entirely. There was a false positive in the go runtime a few years ago… long since been patch and NVM4W never suffered from the exploit anyway… but some AV firms block the entire go language signature.
  4. Truthfully, I never turn nvm off and on. You shouldn’t really have to, but it is designed to help test your system.

Did you run nvm on after the installation?

Note that this issue isn’t just that NPM fails to install, but the NVM command-line utility also fails to recognize that NPM was not installed. IMO the installer is not doing a needed step of verifying that the directory is present, which would avoid some confusion around this issue.

I have McAfee Endpoint Security installed, but as it’s a managed PC in an office, there’s no way to disable it to see if that’s the issue. NPM continues to hang after 10 mins of going into the installation process. Is there not a way to modify NVM to at least detect hangs or that a process is not completed as intended?