繁体   English   中英

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

[英]Node installs with the wrong version of NPM

大家好,我之前发布了这个问题,但没有回复。 我再次发帖希望能得到一些急需的答案。

我正在关注 NodeJS 的教程。 在教程中,它说“安装这个版本的 npm 以跟随”我做了,它是版本 5.5.1。

不幸的是,该版本与我的节点版本不兼容,所以我尝试升级我的 npm 但它也不起作用。 所以大多数帖子都说要重新安装我所做的 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.

同样由于某种原因, npm -v仍然显示 5.5.1。 而且我不认为 Node 12.8.1 附带 NPM 5.5.1。 那么也许我所做的那个覆盖升级仍然存在?

任何帮助是极大的赞赏。

如果你已经安装了 npm 然后卸载它并安装 nvm。 使用 nvm 您可以安装任何版本的节点,也可以安装多个版本的节点。 您可以根据需要切换任何版本的节点。

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

升级 npm 尝试使用 sudo:

sudo npm install -g npm@latest

用 npm 升级 nodejs 试试这个:

sudo npm install -g n 

sudo n latest

这个问题是重复

暂无
暂无

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

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