英文:
Why am I unable to run npm commands on Git Bash?
问题
I changed NodeJS
version using nvm
and now when I'm trying to run any npm
command it throws an error. Event npm -v
doesn't work. Here's the error:
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 https://nodejs.org/.
ERROR:
C:\Users\bazha\AppData\Roaming\npm\node_modules\npm\lib\utils\exit-handler.js:19
const hasLoadedNpm = npm?.config.loaded
npm
works perfectly on windows' terminal and I get no error. The reason I want to use Git Bash is for rm
.
The version of NodeJS
I'm trying to use here is 10.16.2
. I used nvm use 10.16.2
to change the versions. The npm
version that is installed with 10.16.2 nodejs
is 6.9.0
. node -v
on windows' terminal is 10.16.2
node -v
on Git Bash is 10.16.2
npm -v
on windows' terminal is 6.9.0
npm -v
on Git Bash throws the error above
How do I run npm
commands on Git Bash?
英文:
I changed NodeJS
version using nvm
and now when I'm trying to run any npm
command it throws an error. Event npm -v
doesn't work. Here's the error:
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 https://nodejs.org/.
ERROR:
C:\Users\bazha\AppData\Roaming\npm\node_modules\npm\lib\utils\exit-handler.js:19
const hasLoadedNpm = npm?.config.loaded
npm
works perfectly on windows' terminal and I get no error. The reason I want to use Git Bash is for rm
.
The version of NodeJS
I'm trying to use here is 10.16.2
. I used nvm use 10.16.2
to change the versions. The npm
version that is installed with 10.16.2 nodejs
is 6.9.0
. node -v
on windows' terminal is 10.16.2
node -v
on Git Bash is 10.16.2
npm -v
on windows' terminal is 6.9.0
npm -v
on Git Bash throws the error above
How do I run npm
commands on Git Bash?
答案1
得分: 1
错误消息提供了确切的原因:
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.org/.
有三个版本规范,其中至少一个必须满足:
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 中的任何一个标准。错误消息还提供了解决方案:
> You can find the latest version at https://nodejs.org/
因此,你的 Git Bash 使用了一个非常旧的 Node.js 版本。你需要升级 Node.js 版本以解决这个问题。
英文:
The error message provides you the exact reason:
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.org/.
There are three version specifications and at least one of them must be met:
1
^14.17.0
covers 14.17.x versions, where x >= 0
2
^16.13.0
covers 16.13.x versions, where x >= 0
3
>=18.0.0
covers anything above or equal with 18.0.0
Your problem
10.16.2
does not meet any of the criterias from 1, 2 or 3. The error message also gives you the solution:
> You can find the latest version at https://nodejs.org/
Hence, your git bash is using a very old version of Node.js. You will need to upgrade this for your git bash.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论