Windows上的git bash终端中的Node命令不起作用 [英] Node command not working in git bash terminal on windows
问题描述
我正在尝试在git bash终端中运行 node
命令.当我运行 node
命令时,按Enter键时没有任何反应. $
消失了,它只在下一行留下了闪烁的光标,而没有>
.
I'm trying to run the node
command in my git bash terminal. When I run the node
command, nothing happens when I press enter. The $
goes away and it just leaves a blinking cursor on the next line without the >
.
My-PC MINGW32 /
$ node -v
v4.5.0
My-PC MINGW32 /
$ where node
C:\Program Files\nodejs\node.exe
My-PC MINGW32 /
$ node
_
有人可以告诉我这个问题可能是什么吗?
Could someone tell me what the issue could be?
谢谢!
推荐答案
如果在输入节点"后没有得到带有>
的新行-这可能是因为更新版本的Git Bash不在以前的TTY模式下运行.在此处讨论.您可以输入以下内容进行验证:
If you're not getting a new line with a >
after entering "node" - this is probably because newer versions of Git Bash don't run in the TTY mode they used to. Discussion here. You can verify by entering:
node -p -e "Boolean(process.stdout.isTTY)"
如果返回false-那么Node REPL(和其他一些控制台工具)将无法正常工作.
If that returns false - then the Node REPL (and some other console tools) won't work correctly.
有两种解决方法:
winpty node
或者您可以在.bash_profile中添加别名:
Or you can add an alias in your .bash_profile:
alias node="winpty node"
# and for npm CLI/scripts:
alias npm="winpty npm.cmd"
解决方法B
使用以下目标为Git Bash创建新的快捷方式:
Workaround B
Create a new shortcut to Git Bash with the following Target:
"C:\Program Files\Git\git-cmd.exe" --no-cd --command=usr/bin/bash.exe -l -i
并使用它代替默认的Git Bash.
and use that instead of the default Git Bash.
这篇关于Windows上的git bash终端中的Node命令不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!