最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

为什么我无法在 Git Bash 上运行 npm 命令?

网站源码admin35浏览0评论

为什么我无法在 Git Bash 上运行 npm 命令?

为什么我无法在 Git Bash 上运行 npm 命令?

我使用

NodeJS
更改了
nvm
版本,现在当我尝试运行任何
npm
命令时,它会抛出错误。事件
npm -v
不起作用。这是错误:

ERROR: npm v9.6.6 is known not to run on Node.js v10.16.2. 
This version of npm supports the following node versions: `^14.17.0 || ^16.13.0 || >=18.0.0`. You can find the latest version at /.

ERROR:
C:\Users\bazha\AppData\Roaming\npm\node_modules\npm\lib\utils\exit-handler.js:19
  const hasLoadedNpm = npm?.config.loaded

npm
在 Windows 终端上完美运行,我没有收到任何错误。我想使用 Git Bash 的原因是
rm
.

我在这里尝试使用的

NodeJS
版本是
10.16.2
。我使用
nvm use 10.16.2
来更改版本。
npm
安装的
10.16.2 nodejs
版本是
6.9.0
。 Windows终端上的
node -v
10.16.2
node -v
在 Git Bash 上是
10.16.2
Windows终端上的
npm -v
6.9.0
npm -v
在 Git Bash 上抛出上面的错误

如何在 Git Bash 上运行

npm
命令?

回答如下:

错误信息为您提供确切原因:

This version of npm supports the following node versions: `^14.17.0 || ^16.13.0 || >=18.0.0`. You can find the latest version at https://nodejs/.

一共有三个版本规范,至少需要满足其中一个

1

^14.17.0
涵盖 14.17.x 版本,其中 x >= 0

2

^16.13.0
涵盖 16.13.x 版本,其中 x >= 0

3

>=18.0.0
涵盖任何高于或等于 18.0.0

的内容

你的问题

10.16.2
不符合 123 中的任何标准。报错信息也给了你解决方法:

您可以在https://nodejs/

找到最新版本

因此,您的 git bash 使用的是非常旧版本的 Node.js。你需要为你的 git bash 升级它。

发布评论

评论列表(0)

  1. 暂无评论