gpt4 book ai didi

node.js - 'node' 不是内部或外部命令,也不是可运行的程序或批处理文件。在 git bash 中

转载 作者:行者123 更新时间:2023-12-03 12:11:06 34 4
gpt4 key购买 nike

我遇到了这个问题,它说“Node ”未被识别为内部或外部命令,
可运行的程序或批处理文件。当我尝试从 git bash cli 执行 npm start 时。

$ npm start

> queensland-weather@0.1.0 start C:\Users\Admin\Desktop\react\project
> react-scripts start

'node' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Admin\AppData\Roaming\npm-cache\_logs\2018-05-16T01_35_47_855Z-debug.log

但是,如果我从 git bash 执行 node -v 或 npm -v,它会返回我的结果
Derek MINGW64 ~/Desktop/react/project (master)
$ npm -v
5.6.0

Derek MINGW64 ~/Desktop/react/project (master)
$ node -v
v9.5.0

如果我从 windows cmd 执行同样的事情,它会起作用:
Compiled successfully!

You can now view project in the browser.

Local: http://localhost:3000/
On Your Network: http://192.168.10.1:3000/

Note that the development build is not optimized.
To create a production build, use npm run build.

更新:

将 node 和 npm 添加到环境变量中

enter image description here

最佳答案

我一直在寻找这个问题的答案,我得到的只是“将 nodejs 添加到路径”,我已经完成了(实际上是在安装时由 Node 完成的)
最后发现 git bash 对 PATH 变量中的空格很敏感。

所以......最安全的方法是在路径变量之后添加一个斜杠,这样你就可以确定“\nodejs”部分之后没有空格,即

C:\Program Files\nodejs\

关于node.js - 'node' 不是内部或外部命令,也不是可运行的程序或批处理文件。在 git bash 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50361314/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com