命令?"/>
为什么我无法在 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
不符合 1、2 或 3 中的任何标准。报错信息也给了你解决方法:
您可以在https://nodejs/
找到最新版本
因此,您的 git bash 使用的是非常旧版本的 Node.js。你需要为你的 git bash 升级它。
更多推荐
为什么我无法在 Git Bash 上运行 npm 命令?
发布评论