0

Terminal Output

Referring to the above picture, can someone please tell my why my NPM script would continually fail saying that node is not recognized.

nodejs is clearly in my $PATH and it correctly identifies where it is on my computer outside of an npm script.

I am using Git Bash inside ConEMU on Windows Version 10.0.17134 Build 17134.

I wouldn't be surprised if the issue is with Windows, as the problem seems to have popped up since the latest OS update, installed just over a week ago (I've been having this issue for around that same amount of time)

Denno
  • 2,020
  • 3
  • 19
  • 27
  • Why are all the items in your path separated by a `:` (colon). On Windows, they should be separated by a `;` (semi-colon). Or, is this some weird way your shell is showing it? Are you sure the actual path is correctly configured? Can you run node from a regular windows console? – jfriend00 May 27 '18 at 05:32
  • I'm unsure why they're separated by a colon.. When I set them, I use the Environment Variables UI in System Properties. There's no colons or anything in that, so I guess it's how the terminal displays it – Denno May 27 '18 at 05:53
  • Does node run in a generic windows console? You need to isolate whether this is a generic Windows issue or whether it's something to do with your console environment. – jfriend00 May 27 '18 at 05:55
  • Yes, I can run the npm script fine inside a Windows Command Prompt, and inside a Windows PowerShell.. So that would indicate the issue is with Git Bash.. Does Git Bash use a different $PATH when running npm scripts? – Denno May 27 '18 at 05:58
  • Perhaps this is relevant: [Git Bash doesn't see my Windows path](https://stackoverflow.com/questions/10681101/git-bash-doesnt-see-my-path) – jfriend00 May 27 '18 at 06:03
  • Thanks for the suggestion. Unfortunately I have already been studying that question and answers for as long as I've been having this issue, but it doesn't seem to be helping.. I've tried the following in my `.bashrc`: `export PATH="$PATH:/c/nodejs"` and `"PATH=$PATH;/c/nodejs"` and `"PATH=$PATH:/c/nodejs"` and `"PATH=$PATH;C:\nodejs"` and multiple other variations, restarting Git Bash every time to test the result, but nothing has worked – Denno May 27 '18 at 06:12
  • Did you try typing node.exe instead of node as suggested in an answer to that question? – jfriend00 May 27 '18 at 06:13
  • Unfortunately this `npm` script is just a test case.. The issue I'm really having is trying to run `npm install` in one of my projects, but when it comes to installing `node-sass`, npm tries to call node, but can't. So I can't change `node` to `node.exe` – Denno May 27 '18 at 06:15
  • Well, one of those answers says that node.exe is required. I don't know git bash myself. – jfriend00 May 27 '18 at 06:16
  • Which is unfortunately why the answers there aren't helpful for my situation – Denno May 27 '18 at 06:19
  • An open issue on it: [obviate typing the filename extension for Windows executables](https://github.com/Microsoft/WSL/issues/2003) with some suggestions. – jfriend00 May 27 '18 at 06:22
  • My biggest concern is that I've been developing on this machine for years.. Just over a week ago, I had to reinstall my node dependencies due to a security issue that GitHub noticed with one of my dependencies dependencies.. So for it to all of a sudden stop working is incredibly infuriating – Denno May 27 '18 at 06:24
  • Do you have a pathext environment variable? See https://epsil.github.io/blog/2016/04/20/#update-pathext. – jfriend00 May 27 '18 at 06:30
  • I do (looking in Windows' Environment Variables control panel). Value is `.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PHP`. I assume I would be looking for `.EXE`? Which is there – Denno May 27 '18 at 06:34
  • I have finally got it working! Bloody Windows.. I had to move the environment variable from the end all the way to the start.. Clearly Windows didn't like that the $PATH was so long, and therefore wasn't parsing up to the `nodejs` entry -_- – Denno May 27 '18 at 06:38
  • That doesn't explain why it worked fine from a windows command prompt. That sounds more like a Git Bash issue processing a long path, not a Windows issue. Anyway, glad you found a way to fix. – jfriend00 May 27 '18 at 06:42
  • Thanks for talking through options with me – Denno May 27 '18 at 06:43

1 Answers1

1

I have finally got it working! It is, unsurprisingly, a Windows issue.. Because I had a few entries in my $PATH, and the nodejs one was at the end, Windows would silently fail when reading the entire path, and not get as far as the nodejs entry. The fix was to move the nodejs in the Environment Variables control panel to the very top

Denno
  • 2,020
  • 3
  • 19
  • 27