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

Created on 3 Jul 2019  ·  47Comments  ·  Source: coreybutler/nvm-windows

My Environment

  • [x] Windows 10

I'm using NVM4W version:

  • [x] 1.1.7

I have already...

  • [x] read the README to be aware of npm gotchas & antivirus issues.
  • [x] reviewed the wiki to make sure my issue hasn't already been resolved.
  • [x] verified I'm using an account with administrative privileges.
  • [x] searched the issues (open and closed) to make sure this isn't a duplicate.
  • [x] 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+?)
  • [x] 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.

Most helpful comment

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:UsersUSER_NAMEAppDataRoamingnvmv8.11.4).
  3. unzip the file from step 1, and copy node_modules directory to version directory infered in previous step.
  4. npm works

All 47 comments

Are you 100% certain you're running 1.1.7? I ask because the npm/cli change was a hardcoded URL issue that existed in 1.1.6 and was fixed in 1.1.7.

unfortunetly, 100% certain @coreybutler
hahaha

here's my screenshot of the version:

2019-07-03_13h33_44

A friend of mine just installed nvm 1.1.7 on his machine and I upgraded mine as well to get the latest version of npm, with no luck unfortunetly

Sorry, had to ask :-)

I cannot recreate this.

image

Typically it comes down to a) permissions, b) network issue during the download. Sometimes the network issue is on the remote server, especially when a brand new node/npm release has been pushed. This error message crops up all the time, but for lots of different reasons, making it difficult to identify the real source of the issue.

To reproduce this issue I had to uninstall Node and NPM and do a fresh install using only NVM, then I get the error.

pwrshell-nvm-install-latest

I've noticed that during the install process the NPM related stuff is downloaded to a temp folder, but later it's never moved anywhere and the temp folder is deleted.
Even running powershell as Administrator, so I don't think it's permission related.

During install:
during-install

After install:
after-install

@gsicoli You're correct that npm downloads to a temp directory and is then moved. If the move operation is silently failing, it would cause the directory to be deleted without moving npm where it needs to be (i.e. this behavior).

Are you prompted when you run nvm use or nvm install? Running as an administrator doesn't necessarily mean the account has elevated permissions. Typically, Windows will prompt you to elevate permissions. For an admin account, it's automatically granted, but it still requires the user to say "OK".

It prompts when I don't run as administrator. If I run as administrator it doesn't prompt... Nonetheless the effect is the same.

Facing the same issue on Windows 10. If there is any information I can provide, I will be happy to help!

It does not seem to be related to a certain version of node though; the node_modules folder is always empty for the versions I attempt to install. I am prompted for elevated permissions.

Have the same problem. Is there a workaround?

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:UsersUSER_NAMEAppDataRoamingnvmv8.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. So, I have applied workaround from @liuwenzhuang. Indeed, now npm works fine. However, I get following error on npm up -g
62166164-56513a00-b320-11e9-8728-4d0cfeb758a9

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

@helzgate: This makes no sense for me. My virus logs show exactly nothing.
Can you provide a log of your McAfee activity?

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'm running into the same issue, but it seems to happen only with installing node 6 (or happens because I installed node 6 after doing nvm install latest?). NPM installation hangs indefinitely, and I run into the same npm-cli error as listed above.

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?

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

@matthew-dean Same here with McAfee. Though they didn't properly define my permissions so I can disable it. I will see if that is the cause of the issue tomorrow when I am back at work. I wouldn't be surprised; the package installer of dart reported a similar issue when installing some package (which also worked through downloading to temp and then moving somewhere else).

Yup this is indeed the issue for me! There is some operation there that McAfee Endpoint Security silently prevents.

Installing any version with McAfee active => no npm
Installing any version with McAfee disabled => npm is included and working fine

Is the error mentioned above, when executing npm update -g, related to McAfee as well? Or is this a side effect of the workaround?

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)

Thanks! Following an improved version of that script for bash. (You may need to adjust the nodejs location.) Append it to your ~/.bashrc and execute npmup in a new bash. Or, directly execute the commands of function body at once. This version actually does an update, instead of (re-)installation every time.

function npmup {
  pushd /c/Program\ Files/nodejs > /dev/null
  mv npm npm2
  mv npm.cmd npm2.cmd
  mv npx npx2
  mv npx.cmd npx2.cmd
  node node_modules/npm/bin/npm-cli.js up npm -g
  mv -n npm2 npm
  mv -n npm2.cmd npm.cmd
  mv -n npx2 npx
  mv -n npx2.cmd npx.cmd
  rm -f npm2 npm2.cmd npx2 npx2.cmd
  popd > /dev/null
}

The comment I referred to has since been removed, sorry for the confusion.

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.

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.

@hind3nbug Same for me, McAfee Endpoint Security is not disable-able on a corporate machine, so there really still needs to be a proper way to install NPM. There should be some way to do this.

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 :(

@hind3nbug & @coreybutler... so is this issue was resolved? but not released new nvm version? when a new version is estimated?

I had Nodist installed prior to nvm-windows. It left a .npmrc file under home directory (%userprofile%). I had to remove it and try nvm use command again to get everything right.

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

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

Did you run nvm on after the installation?

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'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.

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:UsersUSER_NAMEAppDataRoamingnvmv8.11.4).
  3. unzip the file from step 1, and copy node_modules directory to version directory infered in previous step.
  4. npm works

I tried everything for two days... nvm, node re-install, restarts, PATH changes, and this is the only thing that actually worked like a charm!

@coreybutler can I suggest adding @liuwenzhuang 's suggestion to readme.md or Common-Issues?

This can save someone's time.

Hola, es mi caso, este mensaje en la consola me dió la pista sobre el error:

Please visit https://github.com/npm/npm/releases/tag/v6.14.4 to download npm.

Si vamos a la página https://github.com/npm/npm/, se indica que el repositorio se ha movido y que ahora está en https://github.com/npm/cli. Es decir, que habría que buscar la v6.14.4 en dicho repositorio.

I have also faced same issue on Windows 10. And it can be resolved by disabling the McAffe protection.

Open McAffe Endpoint Security > Threat Prevntion > Disable Access Protection and On access scan module (Uncheck)
run > nvm install version

@coreybutler : I think you should provide some relative notification if npm not installed properly.

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:UsersUSER_NAMEAppDataRoamingnvmv8.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

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

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:UsersUSER_NAMEAppDataRoamingnvmv8.11.4).
  3. unzip the file from step 1, and copy node_modules directory to version directory infered in previous step.
  4. npm works

This worked !!!

I also had the same issue with McAfee + Win 10 + PowerShell. - Many thanks @liuwenzhuang

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?

This comment works for me: https://github.com/coreybutler/nvm-windows/issues/475#issuecomment-538475058

Just doing nvm on... I thought it was 'on' directly after the installation 😄

When your local npm's version is latest, it may not install the same version npm when you installing latest node, does that will happen?

One of my office machine has McAfee and I think it is stoping to install(copying) the npm folder. But below step comes like a rescue for me. Thanks.

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 directory that located in nvm install directory(eg. C:UsersUSER_NAMEAppDataRoamingnvmv8.11.4).
  3. unzip the file from step 1, and copy node_modules directory to version directory inferred in previous step.
  4. npm works

This works from me, like a charm!!

I think, Adding a testing step to confirm about the successful installation of any nodejs version through nvm-windows will be very helpful to save time. If it fails, then provide some probable insights to resolve it.

@coreybutler thought?

Thanks.

@Amitesh - I think having integrity checks is a good idea. However; I don't have time to do that right now (see the discussion tab, first post). I would accept a PR if someone wanted to add this.

I'm still facing issue npm not recognized on windows 10 for newly installed node(10.23.0) using nvm (1.1.7)
I followed the below steps but no use

download the need node version from https://nodejs.org/en/download/releases/ in zip format(or other format)
Delete node_modules directory if it already exist in version directory that located in nvm install directory(eg. C:UsersUSER_NAMEAppDataRoamingnvmv8.11.4).
unzip the file from step 1, and copy node_modules directory to version directory inferred in previous step.
npm works
can someone guide me how to get this working :( @coreybutler any help please?
nvmerror
nvm npm _10 23 0

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
Was this page helpful?
0 / 5 - 0 ratings

Related issues

snerte picture snerte  ·  5Comments

petrovicz picture petrovicz  ·  4Comments

SufyanParkar picture SufyanParkar  ·  4Comments

ctsstc picture ctsstc  ·  3Comments

webspecialist picture webspecialist  ·  5Comments