简体   繁体   English

使用错误版本的 NPM 安装节点

[英]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.我正在关注 NodeJS 的教程。 In the tutorial, it says "install this version of npm to follow along" which i did, and it was version 5.5.1.在教程中,它说“安装这个版本的 npm 以跟随”我做了,它是版本 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.不幸的是,该版本与我的节点版本不兼容,所以我尝试升级我的 npm 但它也不起作用。 So most posts say to re-install Node which I did, but I still get the following error:所以大多数帖子都说要重新安装我所做的 Node,但我仍然收到以下错误:

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.同样由于某种原因, npm -v仍然显示 5.5.1。 And I don't think Node 12.8.1 comes with NPM 5.5.1.而且我不认为 Node 12.8.1 附带 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.如果你已经安装了 npm 然后卸载它并安装 nvm。 Using nvm you can install any version of node and also you can install multiple versions of the node.使用 nvm 您可以安装任何版本的节点,也可以安装多个版本的节点。 you can switch any version of the node as per your requirements.您可以根据需要切换任何版本的节点。

Here is the ref link for install nvm.这是安装 nvm 的参考链接。 https://codeburst.io/nvm-for-windows-how-to-install-and-use-13b7a4209791 https://codeburst.io/nvm-for-windows-how-to-install-and-use-13b7a4209791

for upgrading npm try with sudo:升级 npm 尝试使用 sudo:

sudo npm install -g npm@latest

for upgrading nodejs with npm try this:用 npm 升级 nodejs 试试这个:

sudo npm install -g n 

sudo n latest

this question is duplicate这个问题是重复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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