I'm trying to use node to do a small inline string manipulation of the current PATH in a bash script (in mintty.exe on a GitHub Windows Action Runner), but it's not working as expected. I've recreated the issue in an MSYS2 terminal on my desktop where it was easier to cut it down to the simplest example.

If I run echo $PATH, I get the /c/...:... paths I expect (unix like. forward slashes, colons):

camer@QUASAR MINGW64 ~
$ echo $PATH

If mix another string in, all works as expected, too:

camer@QUASAR MINGW64 ~
$ echo "console.log('$PATH')"

But when I put that string as a -e option to node, it reverts to Windows style paths. Note this doesn't actually run because the backslashes mess up Node's interpretation of the string. It errors on the first \u which it thinks is the start of a unicode character. This, among other reasons, confirm the incorrect $PATH format.

camer@QUASAR MINGW64 ~
$ node -e "console.log('$PATH')"

I cannot for the life of me figure out why...

Windows style path shows up when I don't expect it

Even if I wrap the output of a known working echo ... in node -e "...", it messes it up.

Different path echoed, Windows style



You must log in to answer this question.

Browse other questions tagged .