使用命令:npm install -g npm,报错如下

E:\vue>npm install -g npm
npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: npm@10.2.5
npm ERR! notsup Not compatible with your version of node/npm: npm@10.2.5
npm ERR! notsup Required: {"node":"^18.17.0 || >=20.5.0"}
npm ERR! notsup Actual:   {"npm":"9.6.4","node":"v20.0.0"}

npm ERR! A complete log of this run can be found in: C:\Users\DELL\AppData\Local\npm-cache\_logs\2024-01-09T02_10_29_038Z-debug-0.log

改用如下命令:npm install --force -g npm

E:\vue>npm install --force -g npm
npm WARN using --force Recommended protections disabled.
npm WARN install Forcing global npm install with incompatible version 10.2.5 into node v20.0.0

removed 43 packages, and changed 90 packages in 3s

28 packages are looking for funding
  run `npm fund` for details

查看一下版本:原来版本是9.6.4,现在版本是10.2.5

E:\vue>npm -v
npm WARN cli npm v10.2.5 does not support Node.js v20.0.0. This version of npm supports the following node versions: `^18.17.0 || >=20.5.0`. You can find the latest version at https://nodejs.org/.
10.2.5

但是和当前的node版本不兼容,升级一下node

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐