Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node command not working in git bash terminal on windows

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!!

like image 296
AB10 Avatar asked Sep 05 '16 01:09

AB10


1 Answers

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.

like image 54
Chris B Avatar answered Oct 22 '22 14:10

Chris B