Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvm installs node but fails to deliver npm #456

Closed
8 of 13 tasks
dcoferraz opened this issue Jul 3, 2019 · 63 comments
Closed
8 of 13 tasks

nvm installs node but fails to deliver npm #456

dcoferraz opened this issue Jul 3, 2019 · 63 comments

Comments

@dcoferraz
Copy link

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.

@coreybutler
Copy link
Owner

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.

@dcoferraz
Copy link
Author

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

@coreybutler
Copy link
Owner

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.

@gsicoli
Copy link

gsicoli commented Jul 4, 2019

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

@coreybutler
Copy link
Owner

@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".

@gsicoli
Copy link

gsicoli commented Jul 4, 2019

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

@geisterfurz007
Copy link

geisterfurz007 commented Jul 10, 2019

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.

@Didovgopoly
Copy link

Didovgopoly commented Jul 11, 2019

Have the same problem. Is there a workaround?

@liuwenzhuang
Copy link

liuwenzhuang commented Jul 19, 2019

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

@Niels-75
Copy link

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

@PostImpatica
Copy link

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

@Niels-75
Copy link

Niels-75 commented Aug 1, 2019

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

@maru-sama
Copy link

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?

@matthew-dean
Copy link

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.

@matthew-dean
Copy link

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?

@matthew-dean
Copy link

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

@geisterfurz007
Copy link

@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).

@geisterfurz007
Copy link

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

@Niels-75
Copy link

Niels-75 commented Aug 8, 2019

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

@geisterfurz007
Copy link

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)

@Niels-75
Copy link

Niels-75 commented Aug 10, 2019

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
}

@geisterfurz007
Copy link

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

@hind3nbug
Copy link

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.

@matthew-dean
Copy link

matthew-dean commented Jan 17, 2020

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.

@matthew-dean
Copy link

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

@javnov
Copy link

javnov commented Feb 4, 2020

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

@Shemesh
Copy link

Shemesh commented Feb 11, 2020

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

@ismailkattakath
Copy link

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.

@DinsmoreDesign
Copy link

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

@dtwansel
Copy link

dtwansel commented May 3, 2020

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

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!

@smurugavels
Copy link

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

This can save someone's time.

@jafs
Copy link

jafs commented May 18, 2020

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.

@rajneeshjoshi4
Copy link

rajneeshjoshi4 commented May 27, 2020

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.

@joy2323
Copy link

joy2323 commented Jun 26, 2020

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

@averyfreeman
Copy link

averyfreeman commented Jul 7, 2020

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

@lacroixDj
Copy link

lacroixDj commented Sep 1, 2020

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

This worked !!!

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

@wjhanna
Copy link

wjhanna commented Sep 3, 2020

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?

@PestoP
Copy link

PestoP commented Sep 8, 2020

This comment works for me: #475 (comment)

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

@onemoon
Copy link

onemoon commented Sep 25, 2020

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?

@Amitesh
Copy link

Amitesh commented Oct 26, 2020

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:\Users\USER_NAME\AppData\Roaming\nvm\v8.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.

@coreybutler
Copy link
Owner

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

@Laxmi-laks
Copy link

Laxmi-laks commented Nov 4, 2020

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:\Users\USER_NAME\AppData\Roaming\nvm\v8.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

@zlatinz
Copy link

zlatinz commented Nov 9, 2020

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

@TeemuKoivisto
Copy link

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

After a long time not working with my Windows laptop I decided to update the Node.js version from 8 to 14. Yet I encountered the bug which I assume many others have also faced here. Your comment helped me to pinpoint the cause although your instructions didn't exactly solve my problem.

For me the issue was that nvm uses an environment variable NVM_SYMLINK which is pointed to C:\Program Files\nodejs that, as far as my installation is concerned, isn't used for installation of Node.js. Changing that to the actual installation path inside AppData\Roaming\nvm\<nodejs version> fixed the issue.

@kerriganb
Copy link

in case anyone is still having this issue ... this is what I did to get it to work.

(note: i had version 14.4.0 of node installed outside nvm) - after installing NVM it asked to mange 14.4.0 and i said yes ... i think this is what caused the NPM issue to not work.. ...

  1. nvm uninstall .. .in my case 14.4.0
  2. (i would nvm uninstall any versions you may have done as well ...)
  3. now you can install your version. nvm install
  4. nvm use

hopefully NPM should now work ...

@lukethacoder
Copy link

had similar issues with 15.7.0.

ran nvm install 15.6.0 and copied the npm folder from that install into the 15.7.0 one and works fine.

looks like certain versions dont properly install npm with nvm install

@voltes-7777
Copy link

experienced the same issue with v1.1.5 but mine was installed via chocolatey and also had both nvm and nvm portable previously installed. uninstalled both via chocolatey then installed (not via choco) the current maintenance release 1.1.7. issue solved. glad i didnt hv to go the route of manually copying the folders.

thank you for this tool. hope it gets updated.

@klepon
Copy link

klepon commented Mar 9, 2021

happen to me today using power shell, install node v9.9.0 no npm installed
using command prompt uninstall node v9.9.0, install it again and all work well

@samuelsons
Copy link

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

Worked for me!

@samuelsons
Copy link

samuelsons commented Mar 11, 2021

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
  • I had to wipe my system clean of all old attempts.
  • Started again using the MANUAL install approach in the WIKI, modified the loyalty to the wiki using the suggestion of @liuwenzhuang which was a successful process as I was able to test both node and npm successfully.

NB: I did the two items below:

  • I actually had to turn off the real-time protection of windows defender antivirus.
  • I also did the "nvm on" [which enabled nodeJS version management].

I also tried to install the version you couldn't achieve above, and it was successful, see screenshot below.
Simply using the direct install command "nvm install v12.12.0"

v12 12

@noel-schenk
Copy link

@RonanCodes
Copy link

This worked for me

@meanOtaku
Copy link

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

disable it when installing node using nvm

@Certiman
Copy link

When using Norton 360, disabling its auto-protect allows installation of npm which is otherwise blocked.

@psiservices-josh-valdivieso

I just ran

nvm uninstall NODE_VERSION

then

nvm install NODE_VERSION

and it brought npm back

@tmushayahama
Copy link

Something to check is make sure npm is not being used by another process when trying to update.

@xiaoboRao
Copy link

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.

same case with yours, but when I run cmd as administrator, that problem disappeared !!!! and you can try to install a different node LTS version, good luck

@dchima-ticketline
Copy link

I had a fresh install of Windows 11 with no previous node installation.
In my case the URLs nvm was trying to download from, e.g. https://github.com/npm/npm/releases/tag/v6.14.4 don't exist. I had to download node from https://nodejs.org/en/download/releases/ and unzip the contents to %APPDATA%\nvm\vNODE_VERSION
Worked a treat after that

@adamobrien4
Copy link

I had a variable in my system path for ".../yarn/bin/" and after removing that the issue has gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests