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

Unable to install the latest npm package #500

Closed
1 of 14 tasks
keylowgee opened this issue Dec 13, 2019 · 7 comments
Closed
1 of 14 tasks

Unable to install the latest npm package #500

keylowgee opened this issue Dec 13, 2019 · 7 comments

Comments

@keylowgee
Copy link

keylowgee commented Dec 13, 2019

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:

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

  • npm-windows-upgrade@6.0.1
    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

@keylowgee
Copy link
Author

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

@bladeoflight16
Copy link

bladeoflight16 commented Jan 7, 2020

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
Copy link

myty commented Jan 26, 2020

This works as well. #300 (comment)

@bladeoflight16
Copy link

bladeoflight16 commented Jan 26, 2020

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

@rikertothebridge
Copy link

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.

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

@coreybutler
Copy link
Owner

Some versions of npm have hard-coded paths/permissions that prevent uninstallation. Unfortunately, there's no way to automatically accomplish this. Use the workarounds listed above. This has been documented in the wiki.

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

6 participants