Nvm-windows: Unable to install the latest npm package

Created on 13 Dec 2019  ·  6Comments  ·  Source: coreybutler/nvm-windows

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
  • [x] 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:

Run nvm version if you don't know.

1.1.7.

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

I expect npm-version-windows

Actual Behavior

PS C:\WINDOWS\system32> npm install npm-windows-upgrade -g
C:\Program Files\nodejs\npm-windows-upgrade -> C:\Program Files\nodejs\node_modules\npm-windows-upgrade\bin\npm-windows-upgrade.js

  • [email protected]
    added 72 packages from 51 contributors in 8.124s
    PS C:\WINDOWS\system32> npm-windows-upgrade -p -v latest
    npm-windows-upgrade v6.0.1
    Checked system for npm installation:
    According to PowerShell: C:\Program Files\nodejs
    According to npm: C:\Program Files\nodejs
    Decided that npm is installed in C:\Program Files\nodejs
    Upgrading npm...

Upgrading npm (fallback method)...

You wanted to install npm 6.13.4, but the installed version is 6.9.0.

A common reason is an attempted "npm install npm" or "npm upgrade npm". As of today, the only solution is to completely uninstall and then reinstall Node.js. For a small tutorial, please see https://github.com/felixrieseberg/npm-windows-upgrade#usage.

Please consider reporting your trouble to https://aka.ms/npm-issues.

Debug Information:

node: 12.6.0 | v8: 7.5.288.22-node.14 | uv: 1.30.1 | zlib: 1.2.11 | brotli: 1.0.7 | ares: 1.15.0 | modules: 72 | nghttp2: 1.38.0 | napi: 4 | llhttp: 1.1.4 | http_parser: 2.8.0 | openssl: 1.1.1c | cldr: 35.1 | icu: 64.2 | tz: 2019a | unicode: 12.1 | os: win32 x64 | OS Name: Microsoft Windows 10 Enterprise
OS Version: 10.0.17134 N/A Build 17134

Steps to reproduce the problem:

I would like to get the latest npm package 6.13.4 [no security issues] with node version 12.13.1

Most helpful comment

This worked for me, but I won't swear by it as the answer for everyone:

  1. Use nvm install to set up the node installation.
  2. Execute nvm use to set the current version.
  3. Open it the current version in File Explorer. (From PowerShell, you can do this with explorer.exe $env:NVM_SYMLINK. From Command Prompt, it's explorer.exe %NVM_SYMLINK%.)
  4. Delete the npm, npx, npm.cmd, and npx.cmd files. I don't think there were any ps1 file when I set it up, but it so, delete those, too. Careful. I don't know the full effects of this deletion if the upgrade fails. You should either keep them in Recycle Bin so you can restore them or be prepared to do a full reinstall of the Node version if it fails.
  5. Now that the script is deleted, we have to invoke npm a bit more manually. Here's the PowerShell command to invoke its update command:
    node (Join-Path $env:NVM_SYMLINK 'node_modules\npm\lib\npm.js') install -g npm

This worked for me because when I ran npm install -g npm, the error I was getting was that the top level script files were "outside" the installation, which I assume means that they weren't recognized as managed by it. I don't know why npm thought it didn't control those files, but once they were out of its way, it updated just fine.

All 6 comments

https://nodejs.org/en/blog/vulnerability/december-2019-security-releases/ trying to get the latest npm version for this security issue.

This worked for me, but I won't swear by it as the answer for everyone:

  1. Use nvm install to set up the node installation.
  2. Execute nvm use to set the current version.
  3. Open it the current version in File Explorer. (From PowerShell, you can do this with explorer.exe $env:NVM_SYMLINK. From Command Prompt, it's explorer.exe %NVM_SYMLINK%.)
  4. Delete the npm, npx, npm.cmd, and npx.cmd files. I don't think there were any ps1 file when I set it up, but it so, delete those, too. Careful. I don't know the full effects of this deletion if the upgrade fails. You should either keep them in Recycle Bin so you can restore them or be prepared to do a full reinstall of the Node version if it fails.
  5. Now that the script is deleted, we have to invoke npm a bit more manually. Here's the PowerShell command to invoke its update command:
    node (Join-Path $env:NVM_SYMLINK 'node_modules\npm\lib\npm.js') install -g npm

This worked for me because when I ran npm install -g npm, the error I was getting was that the top level script files were "outside" the installation, which I assume means that they weren't recognized as managed by it. I don't know why npm thought it didn't control those files, but once they were out of its way, it updated just fine.

@myty Again, I can't speak for everyone, but npm-windows-upgrade failed miserably for me. Its error message was even more cryptic and unhelpful than the one I got from npm install -g npm. (I don't recall the exact error message; I think it was just extremely generic.) It's possible we were facing different issues, though.

This works as well. #300 (comment)

This has worked for me in the past, but now ,whilst trying to update npm from 6.13.4 to 6.13.6 (using node 12.16.0), I get the following error:

npm ERR! code EEXIST
npm ERR! path C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\node_modules\.bin\semver
npm ERR! Refusing to delete C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\node_modules\.bin\semver: is outside C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\node_modules\semver and not a link
npm ERR! File exists: C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\node_modules\.bin\semver
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\johns\AppData\Roaming\npm-cache\_logs\2020-02-18T20_00_16_440Z-debug.log

Anybody else hit this issue and been able to resolve? I did try with --force but same error.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eliavmaman picture eliavmaman  ·  6Comments

fredericrous picture fredericrous  ·  3Comments

thany picture thany  ·  4Comments

tomByrer picture tomByrer  ·  4Comments

flpms picture flpms  ·  4Comments