You wanted to install npm 3.7.2, but the installed version is3.3.4.
Closed this issue · 20 comments
λ npm-windows-upgrade
npm-windows-upgrade 1.2.2
? This tool will upgrade npm. Do you want to continue? Yes
? Which version do you want to install? 3.7.2
Upgrading... \
Upgrading (fallback method)... \You wanted to install npm 3.7.2, but the installed version is3.3.4.
Please consider reporting your trouble to http://aka.ms/npm-issues.
Debug Information:
{ http_parser: '2.6.0',
node: '5.5.0',
v8: '4.6.85.31',
uv: '1.8.0',
zlib: '1.2.8',
ares: '1.10.1-DEV',
icu: '56.1',
modules: '47',
openssl: '1.0.2e',
npm: '3.3.4',
os: 'win32 x64' }
Thanks for reporting! Sorry that you're having trouble - do you remember how you installed Node? Also, which version of Windows are you running?
Hi @felixrieseberg,
I used https://nodejs.org/dist/v5.5.0/node-v5.5.0-x64.msi to install Node.
My Win:
OS Name Microsoft Windows 10 Home Single Language
Version 10.0.10586 Build 10586
I was able to upgrade going to my nodejs installation path and executing npm update npm
I had the same issue trying to upgrade from 3.3.0 to the latest (at the time, which on 2016-03-20) version 3.3.8. I was running in a PowerShell 5.0 (the one that comes standard with Windows 10) prompt ("as Administrator").
The following didn't work either (although it claims it did in the emitted output):
- Open a CMD (not PowerShell) prompt via "Run as Administrator"
- npm install npm@3.3.8 -g
- npm --version
still shows 3.3.0 - npm install npm@3.3.8 -g -force
(claims to have installed 3.3.8, but npm --version reveals it is still at 3.3.0)
What else can those of us do if neither npm nor npm-windows-upgrade will upgrade us to the latest npm version?
There are now clearly enough people with this issue that I should do everything I can to fix it. To all of you, thank you so much for reporting. The bad news: I have no idea why this would happen. We upgrade npm by first figuring out which exe Windows calls, and then updating that precise binary.
I'd love to figure out if the culprit is Windows, npm, or Node. Could you do me a favor, and uninstall and then reinstall Node? If that fixes the issue, I can take a more close look at Node.
Yeah! Actuallty, thanks for helping me with figuring this out, because I can't reproduce it on my machine. Let's try a few things - the upgrader tries these methods to figure out where npm lives.
- Run
Get-Command npm | Select-Object -ExpandProperty Definition
from PowerShell. - Run
npm config --global get prefix
Then, we grab the path and do an upgrade right there. That's what we try first. If the upgrade fails, we do a dumb upgrade (npm install -g npm
), which is in most cases pointless.
What I'd love to know:
- What paths are reported by those commands?
- If you go and check, is npm really upgraded there?
- Can you figure out what the heck is running when you execute
npm
?
I know, it's a bit of work, but it'd really help me.
Here is the output from those commands.
The npm paths exist, not sure where to see if it's upgraded or not from that path (although I included the output of npm --version). Edit: nevermind, see next comment.
Also, I saw some errors in npm-debug.log, not sure what created this, but if it helps:
0 info it worked if it ends with ok
1 verbose cli [ 'D:\Programs\NodeJS\node.exe',
1 verbose cli 'C:\Users\me.domain\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'npm@3.8.3',
1 verbose cli '--loglevel',
1 verbose cli 'win' ]
2 warn invalid config loglevel="win"
3 info using npm@3.3.4
4 info using node@v5.9.0
5 silly loadCurrentTree Starting
6 silly install loadCurrentTree
7 silly install readGlobalPackageData
8 silly fetchPackageMetaData npm@3.8.3
9 silly fetchNamedPackageData npm
10 silly mapToRegistry name npm
11 silly mapToRegistry using default registry
12 silly mapToRegistry registry https://registry.npmjs.org/
13 silly mapToRegistry uri https://registry.npmjs.org/npm
14 verbose get https://registry.npmjs.org/npm not expired, no request
15 silly install normalizeTree
16 silly loadCurrentTree Finishing
17 silly loadIdealTree Starting
18 silly install loadIdealTree
19 silly cloneCurrentTree Starting
20 silly install cloneCurrentTreeToIdealTree
21 silly cloneCurrentTree Finishing
22 silly loadShrinkwrap Starting
23 silly install loadShrinkwrap
24 silly loadShrinkwrap Finishing
25 silly loadAllDepsIntoIdealTree Starting
26 silly install loadAllDepsIntoIdealTree
27 silly rollbackFailedOptional Starting
28 silly rollbackFailedOptional Finishing
29 silly runTopLevelLifecycles Starting
30 silly runTopLevelLifecycles Finishing
31 silly install printInstalled
32 verbose stack Error: Refusing to install npm as a dependency of itself
32 verbose stack at checkSelf (C:\Users\me.domain\AppData\Roaming\npm\node_modules\npm\lib\install\validate-args.js:40:14)
32 verbose stack at Array. (C:\Users\me.domain\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\bind-actor.js:15:8)
32 verbose stack at LOOP (C:\Users\me.domain\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\chain.js:15:14)
32 verbose stack at chain (C:\Users\me.domain\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\chain.js:20:5)
32 verbose stack at C:\Users\me.domain\AppData\Roaming\npm\node_modules\npm\lib\install\validate-args.js:15:5
32 verbose stack at C:\Users\me.domain\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\async-map.js:52:35
32 verbose stack at Array.forEach (native)
32 verbose stack at C:\Users\me.domain\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\async-map.js:52:11
32 verbose stack at Array.forEach (native)
32 verbose stack at asyncMap (C:\Users\me.domain\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\async-map.js:51:8)
33 verbose cwd C:\Users\me.domain\AppData\Roaming\npm
34 error Windows_NT 6.1.7601
35 error argv "D:\Programs\NodeJS\node.exe" "C:\Users\me.domain\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install" "npm@3.8.3" "--loglevel" "win"
36 error node v5.9.0
37 error npm v3.3.4
38 error code ENOSELF
39 error Refusing to install npm as a dependency of itself
40 error If you need help, you may report this error at:
40 error https://github.com/npm/npm/issues
41 verbose exit [ 1, true ]
When I run npm
, the AppData path is displayed in that text, but node from 'D:/Programs' is actually running. Is it finding the wrong one? I checked my environment paths and both npm locations are in there.
I tried some of the instructions from here, which after running npm install npm@latest
from the Node install folder, showed version 3.8.2. But the global/AppData version is still 3.3.4 and gives this error when running npm install npm@latest
:
npm ERR! code ENOSELF
npm ERR! Refusing to install npm as a dependency of itself
Then I tried calling npm install -g npm
from Node's install dir (which definitely exists) to install to global:
D:\Programs\NodeJS>npm install -g npm
npm ERR! not a package D:\Programs\NodeJS\npm
npm ERR! addLocal Could not install D:\Programs\NodeJS\npm
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "D:\Programs\NodeJS\node.exe" "D:\Programs\NodeJS\node_modul
es\npm\bin\npm-cli.js" "install" "-g" "npm"
npm ERR! node v5.9.0
npm ERR! npm v3.8.2
npm ERR! path C:\Users\me.domain\AppData\Local\Temp\npm-4688-e114c0d9\unpack-
a6f1cf9c\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall opennpm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\me.domain\A
ppData\Local\Temp\npm-4688-e114c0d9\unpack-a6f1cf9c\package.json'
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\me.domain\A
ppData\Local\Temp\npm-4688-e114c0d9\unpack-a6f1cf9c\package.json'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
For those of you with this issue, I'm guessing that you at some point tried to update NPM yourself, either following the guide in the npm docs, or by some stack overflow answer.
This is what I would do and it will fix it and you should follow ALL of these steps!
Uninstall nodejs, not repair!, UNINSTALL.
Go into %programfiles%\nodejs
and delete the entire folder.
Delete %appdata%\npm
and %appdata%\npm-cache
Edit your PATH and remove everything that references npm (either program files or appdata).
At this point you should have a blank slate. No node packages, no node in your path, nothing.
So then install the latest node from nodejs.org.
Then in powershell as an admin run npm i -g npm-windows-upgrade
then run npm-windows-upgrade
then update to latest npm.
Doing that will fix any path issues you have done, remove any duplicate npm installs, fix other issues that manually upgrading could have introduced.
You will have to reinstall any global packages you may have had. But I assure you this is the best way and permanent way to fix it.
*DO NOT EVER RUN npm install npm
or any derivatives *
Oh sweet, thanks for the writeup. Would you mind if I steal that comment and turn it into a little mini-faq?
@felixrieseberg please do :).
In fact I was thinking of writing a bat or powershell script to do these steps for them. Maybe you can turn that guide into one? Maybe npm-windows-upgrade --hardfix to do it (or a separate script). Then download nodejs and run the installer?
With //build coming up, I'm sort of heads down in other things, but if you PR me a powershell script, I'll turn it into an option ;-)
Otherwise, I'll totally do that within the next weeks.
@felixrieseberg I'm 100% convinced that self upgrading NPM in the various ways you can find in search results is the culprit here. They all have glaring issues, either not including the npmrc file, or installing another npm in the global profile, breaking the path NPM expects to work with, etc.
@felixrieseberg I'll try to write the script soon.
Thank you! Clearing everything out fixed the issue, now to reinstall all my packages.
Okay, thanks everyone - I'll update documentation. Once documented, I'll close this issue, but if anyone finds the time to make PR that automates the "remove all the traces, reinstall" steps, I'd ❤️ it!
I updated the readme, released a new version that provides the information @robertbaker outlined, and created a new issue (#69) to track a script that automates the steps he outlined - so I'm closing this here.