1

Both node and npm is installed prior to running npm install

$ node
Welcome to Node.js v16.15.0.
Type ".help" for more information.
>


$ npm -v
8.11.0

npm install results in "node not recognized as internal or external command"

Console output:

$ npm install
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated sane@4.1.0: some dependency vulnerabilities fixednpm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node -e "try{require('./postinstall')}catch(e){}"
npm ERR! 'node' is not recognized as an internal or external command,npm ERR! operable program or batch file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\sebas\AppData\Local\npm-cache\_logs\2022-05-27T21_00_18_704Z-debug-0.log

full verbose output: https://ctxt.io/2/AADgZHqcEg

Further notes:

  • The result is the same independent of whether I use cmd or git bash
  • Removing node.js and reinstalling doesn't work
  • Looking at the verbose output, it seems to be something to do with core-js?

user variables

enter image description here

system variables

enter image description here


Please help, Im going insane ;_;

Sebastian Nielsen
  • 3,143
  • 4
  • 19
  • 35
  • Please see this related question [here...](https://stackoverflow.com/questions/23412938/node-is-not-recognized-as-an-internal-or-an-external-command-operable-program) – Leon May 27 '22 at 21:21
  • See [this case](https://stackoverflow.com/a/70452751/1871033)! Perhaps you also have a file (instead of only folders) in your `PATH` somewhere? – CherryDT May 27 '22 at 21:34
  • @CherryDT Unfortunately not, I don't have any GRADLE_PATH – Sebastian Nielsen May 27 '22 at 21:36
  • Please read the answer fully. It's not about `GRADLE_PATH` in particular, that's just what happened to be the root cause in that other case and serves as reminder that you may have further variables evaluated. It's about having a file, or a "subdirectory of a file", in `PATH`. – CherryDT May 27 '22 at 21:37
  • 1
    If that's not it, I recommend using Process Monitor to trace the process creation and what environment variables are passed exactly to drill down where it goes wrong. – CherryDT May 27 '22 at 21:42
  • 1
    @CherryDT It worked! It was the environment variables! It might have been that `chocho.exe` file you can see in the pic – Sebastian Nielsen May 27 '22 at 21:49

1 Answers1

0

Credit to @CherryDT

His answer helped me: https://stackoverflow.com/a/70452751/7123519

Long story short, if you have a file or "subdirectory of a file" in PATH then it can corrupt all paths underneath it.

In my case, I had an entry to choco.exe, so I just had to remove it:

enter image description here


Also, try to move the path that is not working all the way to the top.

Sebastian Nielsen
  • 3,143
  • 4
  • 19
  • 35