问题
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