已知 npm v9.5.1 无法在 Node.js v18.16.0 上运行

Kaa*_*aaL 14 node.js npm nvm npm-install

我正在使用 nvm 来管理我的 Node.js 版本。最近,我使用 nvm 安装了 Node.js 版本 18.16.0,但是当我尝试使用 npm 时,收到以下错误消息:

npm v9.5.1 is known not to run on Node.js v18.16.0

我在网上搜索了解决方案,但大多数似乎与安装不同版本的 Node.js 有关。如果可能的话,我想坚持使用 Node.js v18.16.0,因为它是最适合我的项目的版本。

我尝试使用 nvm 卸载并重新安装 Node.js 和 npm,但仍然收到相同的错误消息。

有谁知道为什么我收到此错误消息以及如何解决它?

小智 21

这种现象不是节点问题。

这是nvm版本问题。

如果将nvm更新到最新版本后重新安装node 18.16.0,则可以正常工作。


Kie*_*ran 17

我在 Windows 上一直使用旧版本的 NVM。

转至NVM-windows 发行页面并获取适合您的安装程序。

然后卸载旧的node/npm版本重新安装。请参阅以下步骤。

# run the following to re-install node and npm 
$ nvm list

  * 18.16.0 (Currently using 64-bit executable)
    16.13.2

# get an old version
$ nvm use 16.13.2
Now using node v16.13.2 (64-bit)

# uninstall 
$ nvm uninstall 18.16.0
Uninstalling node v18.16.0... done

# reinstall 
$ nvm install 18.16.0
Downloading node.js version 18.16.0 (64-bit)... 
Extracting node and npm...
Complete
npm v9.5.1 installed successfully.


Installation complete. If you want to use this version, type

# run / use  it 
$ nvm use 18.16.0
Now using node v18.16.0 (64-bit)


Run Code Online (Sandbox Code Playgroud)