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

Can't install npm #551

Closed
1 of 14 tasks
rotexhawk opened this issue Jun 19, 2020 · 12 comments
Closed
1 of 14 tasks

Can't install npm #551

rotexhawk opened this issue Jun 19, 2020 · 12 comments

Comments

@rotexhawk
Copy link

Make sure you have reviewed the common issues and existing issues before submitting a new issue.

If this is a question about how to use NVM4W, please use stackoverflow instead.

If this is an issue regarding antivirus, make sure you search the existing issues first.

My Environment

  • Windows 7 or below (not truly supported due to EOL - see wiki for details)

  • Windows 8

  • Windows 8.1

  • Windows 10

  • Windows 10 IoT Core

  • Windows Server 2012

  • Windows Server 2012 R2

  • Windows Server 2016

  • My Windows installation is non-English.

I'm using NVM4W version: 1.1.7

Run nvm version if you don't know.

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)

I have a user with admin access and I have the latest nvm. When I try to install any version of node the installation passes but the npm folder is always empty. During the installation I checked the temp folder and noticed the zip was downloaded. I also saw that the zip gets properly extracted. I think something fails when npm-cli is moved from the temp folder but the installation doesn't show any error. I always end up with the broken node setup, where npm is missing.

@8secz-johndpope
Copy link

8secz-johndpope commented Jul 2, 2020

UPDATE - this seems to fix things
https://nodejs.org/dist/v12.18.2/node-v12.18.2-x64.msi

@michaelAdewunmi
Copy link

UPDATE - this seems to fix things
https://nodejs.org/dist/v12.18.2/node-v12.18.2-x64.msi

@8secz-johndpope I am having this same issue. However, I am trying to understand this fix and will be so glad to get some clarifications.

So here are my thoughts - Downloading and Installing the nodejs from the official website should fix the issue because, during nodejs installation (using the msi), npm will be installed globally and added as an environmental variable which should definitely fix the issue. However, this means anytime we call "npm" from the command line, it ends up calling the global npm instead of calling an npm that is tied to the version of node we instructed nvm to use via nvm use <version>. If this is the case, I feel this defeats the purpose of using the version manager. Please let me know your thoughts.

I hope you understand all I have said above. Please let me know if something is wrong with my thoughts - as regards how nvm does its work. I will also love to get this fixed at my end and will want to know if your fix is the way to go. Thanks a lot!

@michaelAdewunmi
Copy link

@8secz-johndpope I think what I said about creating an environmental variable might be wrong. I can see what happens is that the system checks the installed nodejs folder for an npm file and an npm.cmd file (and a node_modules/npm/bin directory) whenever we type npm in the command line. It's clear now Thanks. I have one other question though. Please read on.

By default, After installing nvm, it puts a nodejs shortcut in your Program Files directory. This shortcut automatically links to the active nodejs in use by nvm (active nodejs that must have been set using the command nvm use <version>). So, Please @8secz-johndpope, can you check if, after the fix, it was still the same shortcut to nodejs that's in your Program Files or the shortcut was replaced with an actual nodejs folder.

However, I tried your fix on one of the nodejs versions I installed via nvm (I had installed multiple versions of nodejs and none of them had npm installed). So, I downloaded the msi file for one of the nodejs versions.

Note: Before installing, I had to tell nvm to use the nodejs version whose msi I just downloaded. I did this by first running nvm use <version> to ensure that the npm is installed in the right directory. Also, I did a custom installation and unchecked all installations except npm. (Meaning only npm should be installed while nodejs itself is ignored). I dont know if this is the reason why everything worked well and nvm still controls the version management. @8secz-johndpope I will love to know if you have multiple installations and if you went through all these hassles. Thanks. I'm glad it's all fixed though.

@j0ker-26
Copy link

I got the same problem. waiting....

@Xeinn
Copy link

Xeinn commented Oct 5, 2020

Also currently dealing with exactly the same issue.

@8secz-johndpope
Copy link

@Xeinn I'm not on windows these days - but try to install node.js from here https://nodejs.org/en/
if someone can help respond to @michaelAdewunmi - that would be neat.

@Xeinn
Copy link

Xeinn commented Oct 5, 2020

@8secz-johndpope Thanks for the link and note, have resolved the issue myself with a similar approach you mention.

  1. Install nvm
  2. Manually download zip package for node and unzip into nvm folder sub directory for the version (eg v12.18.4)
  3. nvm then seems to switch between versions properly even if it can't download and install them

Installing node using installer hits issues if you need to install an earlier version - on windows the msi installer doesn't allow you to proceed.

Above worked for me but is obviously less convenient than installing via nvm itself, be good if the cause could be found and fixed, but at least I can work around it for now.

I suspect for the above to work properly you do need to make sure your environment variables are clear of all but the NVM created entries for adding node to the path etc.

@coreybutler
Copy link
Owner

This is often a symptom of not uninstalling prior versions of Node or removing stale npm installations prior to installing NVM4W. This is why the README states these activities need to occur before installing NVM4W.

If you've followed the instructions and still see this error, other potential causes are permissions (i.e. not running as an admin), or in certain circumstances, npm itself. There were a few versions of npm (cannot remember specific npm versions, but the were released in the 8.x.x and 12.x.x Node installs respectively) which shipped with hard coded paths, causing these kinds of problems. This is why specific installations of (using msi's) work while version managers do not (this is not specific to NVM4W).

@OrangeDog
Copy link

This is probably caused by AV scanning, and is a duplicate of #364

@MynockSpit
Copy link

In my case, it's probably not working b/c there is no such release. NPM was moved to https://github.com/npm/cli.

Downloading node.js version 12.20.1 (64-bit)...
Complete
Downloading npm version 6.14.10... Download failed. Rolling Back.
Rollback failed. remove C:\Users\Nathaniel\AppData\Roaming\nvm\temp\npm-v6.14.10.zip: The process cannot access the file because it is being used by another process.
Could not download npm for node v12.20.1.
Please visit https://github.com/npm/npm/releases/tag/v6.14.10 to download npm.
It should be extracted to C:\Users\Nathaniel\AppData\Roaming\nvm\v12.20.1

@samuelsons
Copy link

@8secz-johndpope I think what I said about creating an environmental variable might be wrong. I can see what happens is that the system checks the installed nodejs folder for an npm file and an npm.cmd file (and a node_modules/npm/bin directory) whenever we type npm in the command line. It's clear now Thanks. I have one other question though. Please read on.

By default, After installing nvm, it puts a nodejs shortcut in your Program Files directory. This shortcut automatically links to the active nodejs in use by nvm (active nodejs that must have been set using the command nvm use <version>). So, Please @8secz-johndpope, can you check if, after the fix, it was still the same shortcut to nodejs that's in your Program Files or the shortcut was replaced with an actual nodejs folder.

However, I tried your fix on one of the nodejs versions I installed via nvm (I had installed multiple versions of nodejs and none of them had npm installed). So, I downloaded the msi file for one of the nodejs versions.

Note: Before installing, I had to tell nvm to use the nodejs version whose msi I just downloaded. I did this by first running nvm use <version> to ensure that the npm is installed in the right directory. Also, I did a custom installation and unchecked all installations except npm. (Meaning only npm should be installed while nodejs itself is ignored). I dont know if this is the reason why everything worked well and nvm still controls the version management. @8secz-johndpope I will love to know if you have multiple installations and if you went through all these hassles. Thanks. I'm glad it's all fixed though.

Hi, were you able to get this right.?

@coreybutler
Copy link
Owner

These issues have been addressed in 1.1.7 and 1.1.8. From node 16.9.0 and up, NVM4W uses a new distribution file that bundles node and npm in a single download. This feature is available in https://github.com/coreybutler/nvm-windows/releases/tag/1.1.8

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

9 participants