felixrieseberg / npm-windows-upgrade

:rocket: Upgrade npm on Windows
MIT License
2.53k stars 148 forks source link

Upgrading the Visual Studio 2017 default npm fails: automation? #117

Open natalie-o-perret opened 7 years ago

natalie-o-perret commented 7 years ago

It seems that the version of npm that comes with Visual Studio 2017 is a bit outdated and hence makes the upgrade impossible (I needed to upgrade my version of npm since node-sass has some issues with my current version):

$ npm-windows-upgrade
npm-windows-upgrade v4.0.1
? Which version do you want to install? 5.4.0
Checked system for npm installation:
According to PowerShell: C:\Program Files\nodejs
According to npm:        C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External
Decided that npm is installed in C:\Program Files\nodejs
Upgrading npm... \

Upgrading npm (fallback method)... |

You wanted to install npm 5.4.0, but the installed version is 1.3.2.

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 http://aka.ms/fix-npm-upgrade.
Please consider reporting your trouble to http://aka.ms/npm-issues.

Debug Information:

http_parser: 2.6.0node: 5.4.1v8: 4.6.85.31uv: 1.8.0zlib: 1.2.8ares: 1.10.1-DEVicu: 56.1modules: 47openssl: 1.0.2eos: win32 x64OS Name: Microsoft Windows 7 Enterprise
OS Version: 6.1.7601 Service Pack 1 Build 7601

Is there anything that can be done in that regard? I mean in all fairness, I can-reinstall the whole thing by myself, but I really would like to see some automation in order to avoid wasting time on it.

refack commented 7 years ago

@ehouarn-perret are you sure don't have an old node version in C:\Program Files\nodejs

According to PowerShell: C:\Program Files\nodejs
According to npm:        C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External
Decided that npm is installed in C:\Program Files\nodejs

P.S. @felixrieseberg http://aka.ms/fix-npm-upgrade is dead.

natalie-o-perret commented 7 years ago

@refack just double-checked the version of the Node located in C:\Program Files\nodejs is 8.4.0 which as of today and according to Node website is the latest one (https://nodejs.org/en/download/current/): Latest Current Version: v8.4.0 (includes npm 5.3.0) I can't recall if the one I setup via chocolatey or I used the setup from the Node official website.

But the version located here: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External which is 5.4.1.0 (with npm 1.3.2), this is the one I would like to update:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External
$ npm.cmd install --global --production npm-windows-upgrade

Which btw led to a couple of unmet dependencies:

npm info install npm-windows-upgrade@4.0.1
npm info postinstall npm-windows-upgrade@4.0.1
npm WARN unmet dependency C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External\node_modules\node-gyp requires nopt@'2 || 3' but will load
npm WARN unmet dependency C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External\node_modules\nopt,
npm WARN unmet dependency which is version 1.0.10
npm WARN unmet dependency C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External\node_modules\npm-package-arg requires semver@'4 || 5' but will load
npm WARN unmet dependency C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External\node_modules\semver,
npm WARN unmet dependency which is version 2.3.2
npm WARN unmet dependency C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External\node_modules\uglify-js requires optimist@'~0.3.5' but will load
npm WARN unmet dependency C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External\node_modules\optimist,
npm WARN unmet dependency which is version 0.6.1
npm-windows-upgrade@4.0.1 C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External\node_modules\npm-windows-upgrade

The detection of the path seems to not take in account the related npm: Decided that npm is installed in C:\Program Files\nodejs

While the Node.exe is right besides the npm.cmd, in: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External

Side note: thanks, forgot to mention about http://aka.ms/fix-npm-upgrade

refack commented 7 years ago

@ehouarn-perret I'm coming from node core, only an observer here. It's up to @felixrieseberg to define the scope of this tool. Although I believe if you figure out a way to improve the functionality and open a PR it would be appreciated.

I just checked, the npm version laid down by VS2017 is 3.3.4, the very old version you have (1.3.2) was probably manually installed:

C:\>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Web\External\npm.cmd" -v
3.3.4

So you could try to run:

npm-windows-upgrade --npm-version latest --npm-path "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Web\External\"
natalie-o-perret commented 7 years ago

@refack Same old:

npm-windows-upgrade --npm-version latest --npm-path "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External"
npm-windows-upgrade v4.0.1
Given path C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External is a valid directory.
Upgrading npm... /

Upgrading npm (fallback method)... /

You wanted to install npm 5.3.0, but the installed version is 1.3.2.

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 http://aka.ms/fix-npm-upgrade.
Please consider reporting your trouble to http://aka.ms/npm-issues.

Debug Information:

http_parser: 2.6.0node: 5.4.1v8: 4.6.85.31uv: 1.8.0zlib: 1.2.8ares: 1.10.1-DEVicu: 56.1modules: 47openssl: 1.0.2eos: win32 x64OS Name: Microsoft Windows 7 Enterprise
OS Version: 6.1.7601 Service Pack 1 Build 7601

I don't recall having installed / reinstalled that old version. Besides, I just checked the Node version provided with a brand new installation of Visual Studio 2017 (Enterprise Edition): 5.4.1

Also backed by this post on StackOverflow: https://stackoverflow.com/a/44465593/4636721