javascript sh.exe”:节点:找不到命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8543296/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
sh.exe": node: command not found
提问by Jitendra Vyas
I'm trying to run a javascript file in Gitbash but getting this error.
我正在尝试在 Gitbash 中运行一个 javascript 文件,但出现此错误。
$ node chrome-devtools-autosave-server/index.js
sh.exe": node: command not found
Screenshot
截屏
How to solve this?
如何解决这个问题?
My OS is Windows 7 (64 Bit)
我的操作系统是 Windows 7(64 位)
回答by alessioalex
Node is not 'visible' in MINGW32 by default, only in the Windows Command Terminal. Same goes for npm.
默认情况下,节点在 MINGW32 中不“可见”,仅在 Windows 命令终端中。npm 也是一样。
How to add it (if you have Node installed), from the official MINGW FAQ:
如何添加它(如果您安装了 Node),来自官方 MINGW 常见问题解答:
MSYS uses a Bourne-like shell, hence you can change the PATH using the export command.
The easiest way to add something to the end of the PATH is with the command:export PATH=$PATH:directory-to-add
MSYS 使用类似 Bourne 的 shell,因此您可以使用 export 命令更改 PATH。
在 PATH 末尾添加内容的最简单方法是使用以下命令:export PATH=$PATH:directory-to-add
So you have to add the directory where Node is installed (probably something like C:\Program Files\nodejs).
所以你必须添加 Node 的安装目录(可能类似于 C:\Program Files\nodejs)。
回答by Pravin Kottawar
You are missing double quotes for path varible
您缺少路径变量的双引号
export PATH=$PATH:"C:\Program Files\nodejs"
导出 PATH=$PATH:"C:\Program Files\nodejs"
回答by courtyen
For me, I am using the Git Bash Shell, and what I had to do to add the bin file to my PATH variable is use this syntax:
对我来说,我使用的是 Git Bash Shell,而将 bin 文件添加到我的 PATH 变量中我必须使用以下语法:
export PATH=$PATH:"c/bin/node"
You would think that it would be
你会认为它会是
export PATH=$PATH:"C:\bin\node"
but that wasn't working for me. Hope this helps others that are running into the same issue.
但这对我不起作用。希望这可以帮助其他遇到相同问题的人。