简体   繁体   中英

Node installs with the wrong version of NPM

Hey guys, I previously posted this question but with no reply. I'm posting again to hopefully get some much needed answers.

I'm following a tutorial for NodeJS. In the tutorial, it says "install this version of npm to follow along" which i did, and it was version 5.5.1.

Unfortunately, the version wasn't compatible with my node version so I tried to upgrade my npm but it wouldn't work either. So most posts say to re-install Node which I did, but I still get the following error:

C:\Users\Admin>npm install npm@latest -g
npm WARN npm npm does not support Node.js v12.18.1
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
WARNING: You are likely using a version of node-tar or npm that is incompatible with this version of 
Node.js.
Please use either the version of npm that is bundled with Node.js, or a version of npm (> 5.5.1 or < 
5.4.0) or node-tar (> 4.0.1) that is compatible with Node.js 9 and above.
npm[7656]: c:\ws\src\node_zlib.cc:575: Assertion `args.Length() == 7 && "init(windowBits, level, 
memLevel, strategy, writeResult, writeCallback," " dictionary)"' failed.

Also for some reason, npm -v still displays 5.5.1. And I don't think Node 12.8.1 comes with NPM 5.5.1. So maybe that over-written upgrade I did is still there?

Any help is greatly appreciated.

If you had installed npm along then uninstall it and install nvm. Using nvm you can install any version of node and also you can install multiple versions of the node. you can switch any version of the node as per your requirements.

Here is the ref link for install nvm. https://codeburst.io/nvm-for-windows-how-to-install-and-use-13b7a4209791

for upgrading npm try with sudo:

sudo npm install -g npm@latest

for upgrading nodejs with npm try this:

sudo npm install -g n 

sudo n latest

this question is duplicate

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM