Comments (17)
I think this is more of a previous npm version bug than nvm one.
However, to update npm delete in nvm/[node version]
folder (for me it is v10.15.3
) following files:
C:\Users\[user name]\AppData\Roaming\nvm\[node version]\npm
C:\Users\[user name]\AppData\Roaming\nvm\[node version]\npm.cmd
C:\Users\[user name]\AppData\Roaming\nvm\[node version]\npx
C:\Users\[user name]\AppData\Roaming\nvm\[node version]\npx.cmd
Rename npm folder to npm2
C:\Users\[user name]\AppData\Roaming\nvm\[node version]\node_modules\npm2
Open any console with admin rights (or even right mouse click on vscode shortcut, than right mouse click on Visual Studio Code and hit Run as administrator) and type commands:
cd C:\Users\[user name]\AppData\Roaming\nvm\[node version]\node_modules\npm2\bin
node npm-cli.js i -g npm@latest
Done.
Delete C:\Users\[user name]\AppData\Roaming\nvm\[node version]\node_modules\npm2
folder.
from nvm-windows.
Heya, I just wanted to add that upgrading updating npm isn't quite as simple as just npm update npm
:
$ npm update npm -g
npm ERR! path C:\Program Files\nodejs\npm.cmd
npm ERR! code EEXIST
npm ERR! Refusing to delete C:\Program Files\nodejs\npm.cmd: is outside C:\Program Files\nodejs\node_modules\npm and not a link
npm ERR! File exists: C:\Program Files\nodejs\npm.cmd
npm ERR! Move it away, and try again.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\kamik\AppData\Roaming\npm-cache\_logs\2017-08-24T07_56_26_609Z-debug.log
(I used -g
here but I assume that's what you meant since you didn't say anything about going into the global directory. But if that is what you meant, I'm just describing the same thing in more detail.)
Here is a list of the things you need to do when not using NVM on the official npm wiki: https://github.com/npm/npm/wiki/Troubleshooting#upgrading-on-windows.
But there's actually an easier way if you're using NVM. Since NVM links both binaries and folders, you can just go and update the original global node modules manually. This doesn't require neither admin permissions nor moving files around.
First run node -v
and take note of the version of node you're using (e.g v6.11.1
). Then do this:
cd %appdata%\nvm\6.11.1
npm install npm@latest --no-save
The --no-save
option is important to prevent npm from trying to find package.json
in that directory, and from auto creating package-lock.json
(in npm5 and up).
from nvm-windows.
Windows 10, PowerShell:
PS> nvm list
PS> cd "$env:APPDATA\nvm\v99.99.9"
PS> npm install npm --no-save
(Change digits to the node version where you want to update npm.)
from nvm-windows.
@createdbyjurand I updated your script so that you don't have to edit the script to run it, even when switching versions of node. I also took out @next because that installs a pre-release (non-stable).
$starting_path = Get-Location
$node_version = node -v
$node_path = "$env:appdata\nvm\$node_version"
Write-Host "node_version: $node_version"
Write-Host "Path used: $node_path"
cd $node_path
Remove-Item npm
Remove-Item npm.cmd
Remove-Item npx
Remove-Item npx.cmd
cd node_modules
Rename-Item npm -NewName npm-old
cd npm-old\bin
node npm-cli.js install -g npm
cd ../..
Remove-Item -Recurse -Force npm-old
cd $starting_path
from nvm-windows.
Just run npm update npm
... same as without NVM for Windows.
from nvm-windows.
I think this is more of a previous npm version bug than nvm one.
However, to update npm delete in
nvm/[node version]
folder (for me it isv10.15.3
) following files:C:\Users\[user name]\AppData\Roaming\nvm\[node version]\npm C:\Users\[user name]\AppData\Roaming\nvm\[node version]\npm.cmd C:\Users\[user name]\AppData\Roaming\nvm\[node version]\npx C:\Users\[user name]\AppData\Roaming\nvm\[node version]\npx.cmd
Rename npm folder to npm2
C:\Users\[user name]\AppData\Roaming\nvm\[node version]\node_modules\npm2
Open any console with admin rights (or even right mouse click on vscode shortcut, than right mouse click on Visual Studio Code and hit Run as administrator) and type commands:
cd C:\Users\[user name]\AppData\Roaming\nvm\[node version]\node_modules\npm2\bin node npm-cli.js i -g npm@latest
Done.
Delete
C:\Users\[user name]\AppData\Roaming\nvm\[node version]\node_modules\npm2
folder.
The only solution that worked for me.
from nvm-windows.
Thank you so very much to @createdbyjurand. This worked flawlessly! I wrote a script for it for PowerShell, if anyone wants it; you can run it form anywhere as long as you update the node version being updated (substitute both instances of Username and Version of Node with your own):
cd C:\Users\<Username>\AppData\Roaming\nvm\<Version of Node>
Remove-Item npm
Remove-Item npm.cmd
Remove-Item npx
Remove-Item npx.cmd
cd node_modules
Rename-Item npm -NewName npm-old
cd npm-old\bin
node npm-cli.js install -g npm@next
cd C:\Users\<Username>\AppData\Roaming\nvm\<Version of Node>\node_modules
Remove-Item -Recurse -Force npm-old
Run with the usual .\<filename>.ps1
from anywhere. π
from nvm-windows.
I am using Windows 10 and I spent a whole day on updating pm. Nothing worked but following.
https://www.wdiaz.org/update-npm-when-node-was-installed-using-chocolatey-on-windows/
Steps 1: Copy and Paste the following lines into a file somewhere in your directories and give it the .cmd extension.
Step 2: Double click the newly created "above" file.
You should be good to go now with the most up to date version of node.
from nvm-windows.
The solution outlined by @createdbyjurand does work but has to be repeated every time you install a new version of node. It also causes the following error message updating npm after the initial workaround:
js-algos-structures $ npm install -g npm@latest
C:\Users\jzrai\scoop\apps\nvm\current\nodejs\nodejs\npx -> C:\Users\jzrai\scoop\apps\nvm\current\nodejs\nodejs\node_modules\npm\bin\npx-cli.js
C:\Users\jzrai\scoop\apps\nvm\current\nodejs\nodejs\npm -> C:\Users\jzrai\scoop\apps\nvm\current\nodejs\nodejs\node_modules\npm\bin\npm-cli.js
+ [email protected]
updated 2 packages in 32.004s
C:\Users\jzrai\projects\js-algos-structures>npm-cli.js" install -g npm@latest
'npm-cli.js" install -g npm@latest' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\jzrai\projects\js-algos-structures>ENDLOCAL
C:\Users\jzrai\projects\js-algos-structures>EXIT /b
I don't understand the inner workings enough to know if this is a bug with nvm, npm or scoop but, as it seems to be nvm, I think this issue should be reopened @coreybutler as updating npm is quite a fundamental operation which is currently completely broken with this set-up.
At the very least @createdbyjurand's workaround should be documented more visibly.
If this is definitely a bug with npm I will happily post an issue there.
from nvm-windows.
Thanks to @createdbyjurand !
I needed to update in C:\ProgramData\nvm\
rather than C:\Users\[user name]\AppData\Roaming\nvm
in case that helps anyone else.
from nvm-windows.
I just updated with npm install -g npm@latest
cd
to current node directoryC:\Users\user_name\AppData\Roaming\nvm\v12.8.1
- run
npm install -g npm@latest
Working great Thank you @filipesilva
from nvm-windows.
@coreybutler this might be more headache than it is worth, but as you say
It merely downloads the npm archive and extracts it to the appropriate installation folder. That's it.
Couldn't we then say that NVM's responsibility starts (and ends) at the installation of NPM? If so I feel like my concerns can be addressed by having something like nvm update-npm latest
or something similar. This would in theory take the current version of node and install the specified version of npm to it. It could use a method similar to what's being outlined by @createdbyjurand or something simpler.
You mentioned that you also verified an issue exists in the official node release MSI install. Can you clarify what issue you verified? Was it with an older MSI installation that shipped with an older NPM? I'm running a clean system that hasn't had any node or npm installed prior to NVM and I'm running into these issues.
from nvm-windows.
I just spent hours trying to pinpoint the cause of this error before coming across this comment. Maybe this workaround should be displayed more clearly or this issue reopened as I'm sure trying to update npm with the standard command is quite a common operation and currently it fails and gives the very esoteric error message shown above.
from nvm-windows.
It worked for me, too. Thanks! :)
from nvm-windows.
Awesome help @createdbyjurand cheers
from nvm-windows.
Thank you, @createdbyjurand ! I have been pulling my hair out trying to figure out why the regular commands were not working. This is fantastic! π―
from nvm-windows.
@raikesy - npm and nvm have no operational relationship... meaning nvm just leaves npm alone. It merely downloads the npm archive and extracts it to the appropriate installation folder. That's it.
NVM4W doesn't touch the executable files. Unlike nvm for *nix, there is no shim. When node.exe
is executed, it's actually calling that file. There is literally nothing else running. npm calls node.exe
internally whenever it executes a script, i.e. node npm-cli.js
.
Tools like scoop, homebrew, chocolatey, etc may or may not modify behavior. I don't really know because I don't maintain those. However; I don't think any of those are the problem because I can replicate these problems with standard Node installs (i.e. no nvm4w, no package manager, just a straight up msi install from nodejs.org).
@createdbyjurand is correct that this behavior often comes from older versions of npm. npm has gone through a number of rather difficult design decisions, especially with versions shipping in the Node 8.x.x line where there were some hard-coded path files used for installation.
from nvm-windows.
Related Issues (20)
- [Bug/Feature?]: pnpm leaves files in nodejs install dir, breaking nvm install HOT 1
- [Feature]: Can this work on Linux in powershell? HOT 3
- "nvm list available" doesn't fails with error 404 HOT 5
- [Issue]: Missing newline in `nvm uninstall` message HOT 2
- [Issue]: When Windows username contains umlaut the installer fails HOT 3
- [Issue]: Loading NVM in Git Bash shell takes 10+ seconds HOT 1
- [Issue]: spaces in the installation path of nvm lead to errors using it HOT 2
- [Issue]: unable to install latest node HOT 1
- [Issue]: Invalid settings generation on install when user name contains non-ASCII characters HOT 6
- [Issue]: npm install -g @vue/cli 'vue' δΈζ―ε ι¨ζε€ι¨ε½δ»€οΌδΉδΈζ―ε―θΏθ‘ηη¨εΊ ζζΉε€ηζδ»Άγ HOT 1
- [Issue]: `nvm use` command does not select any version HOT 4
- [Issue]: version changing and alternative try install.ps1 file miss issue HOT 4
- [Issue]: nvm.exe hangs when started by TeamCity because Stdout is not a character mode device HOT 3
- [Issue]: Unable to accept license agreement on the installation dialog HOT 1
- [Issue]: Symlink seems not working in exFAT filesystem HOT 2
- [Issue]: An existing connection was forcibly closed by the remote host. HOT 3
- [Issue]: Doesn't function correctly when settings.txt isn't ascii format HOT 2
- [Issue]: npm i taking to long when running through nvm-windows HOT 1
- [Issue]: NVM for Windows should be run from a terminal such as CMD or PowerShell. HOT 3
- [Issue]: nvm use command does not select certain versions HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nvm-windows.