Node command not working in git bash terminal on windows

佐手、 提交于 2020-01-22 10:57:08

问题


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?

Thanks!!


回答1:


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)"

If that returns false - then the Node REPL (and some other console tools) won't work correctly.

There are a couple workarounds:

Workaround A

winpty node

Or you can add an alias in your .bash_profile:

alias node="winpty node"

# and for npm CLI/scripts:
alias npm="winpty npm.cmd"

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

and use that instead of the default Git Bash.



来源:https://stackoverflow.com/questions/39322780/node-command-not-working-in-git-bash-terminal-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!