Quantcast
Channel: A shell script to check the version of NodeJS doesn't work in Git Bash on Windows - Stack Overflow
Viewing all articles
Browse latest Browse all 2

A shell script to check the version of NodeJS doesn't work in Git Bash on Windows

$
0
0

I am trying to make a shell script to automatically download, compile and build some program I've made. You can see the full script on my blog. My program requires NodeJS 11 or newer, so I am trying to make my script output an appropriate error message in case it's not installed. Here is what I've tried:

node_version=$(node -v) # This does not seem to work in Git Bash on Windows.# "node -v" outputs version in the format "v18.12.1"node_version=${node_version:1} # Remove 'v' at the beginningnode_version=${node_version%\.*} # Remove trailing ".*".node_version=${node_version%\.*} # Remove trailing ".*".node_version=$(($node_version)) # Convert the NodeJS version number from a string to an integer.if [ $node_version -lt 11 ]then  echo "NodeJS version is lower than 11 (it is $node_version), you will probably run into trouble!"fi

However, when I try to run it in Git Bash on Windows 10, with NodeJS 18 installed and in PATH, here is what I get:

stdout is not a ttyNodeJS version is lower than 11 (it is 0), you will probably run into trouble!

What is going on here?


Viewing all articles
Browse latest Browse all 2