Node.js ENOENT Error

Hi, I was working on downgrading the node.js version and after all that i came across this error.

C:\Users\weeseong.hew>npm install node-red-contrib-modbus
npm ERR! code ENOENT
npm ERR! syscall spawn C:\Program Filed\git\bin\bash.exe
npm ERR! path C:\Users\weeseong.hew\node_modules\@serialport\bindings
npm ERR! errno ENOENT
npm ERR! enoent spawn C:\Program Filed\git\bin\bash.exe ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

I recall the last thing I did was setting "npm config set script-shell "C:\Program Files\git\bin\bash.exe"", is there a way to reverse that? Was trying to install nvm and was trying to fix the bash issue.

EDIT: I just changed that with "npm config set script-shell "C:\WINDOWS\system32\cmd.exe"" and it brought me with this error:

C:\Users\weeseong.hew>npm install node-red-contrib-modbus
npm ERR! code ENOENT
npm ERR! syscall spawn =
npm ERR! path C:\Users\weeseong.hew\node_modules\@serialport\bindings
npm ERR! errno ENOENT
npm ERR! enoent spawn = ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

Think i got it worse... should I consider reinstalling?

I imagine that should be Program Files not Program Filed. As to why it is looking there I have no idea. Something on your system is messed up.

As a secondary issue you should be installing from your .node-red folder not your user folder.

Yea think I had a typo when writing down that cmd. I've just reinstalled the whole node-red and it seems to be working now but it came to a problem which I can't seem to install node-red-contrib-modbus. It shows the following error:

2021-07-19T07:51:12.490Z Install : node-red-contrib-modbus 5.14.0

2021-07-19T07:51:12.493Z npm.cmd install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production node-red-contrib-modbus@5.14.0
2021-07-19T07:51:28.098Z [err] npm
2021-07-19T07:51:28.098Z [err]  ERR!
2021-07-19T07:51:28.098Z [err]  code ENOENT
2021-07-19T07:51:28.098Z [err] npm ERR! 
2021-07-19T07:51:28.098Z [err] syscall spawn =
2021-07-19T07:51:28.098Z [err] npm
2021-07-19T07:51:28.098Z [err]  ERR! path C:\Users\weeseong.hew\.node-red\node_modules\@serialport\bindings
2021-07-19T07:51:28.098Z [err] npm ERR!
2021-07-19T07:51:28.098Z [err]  errno
2021-07-19T07:51:28.099Z [err]  ENOENT
2021-07-19T07:51:28.103Z [err] npm
2021-07-19T07:51:28.103Z [err]  
2021-07-19T07:51:28.104Z [err] ERR!
2021-07-19T07:51:28.104Z [err]  enoent spawn = ENOENT
2021-07-19T07:51:28.104Z [err] npm ERR! 
2021-07-19T07:51:28.104Z [err] enoent This is related to npm not being able to find a file.
2021-07-19T07:51:28.104Z [err] npm ERR! enoent 
2021-07-19T07:51:28.149Z [err] 
2021-07-19T07:51:28.149Z [err] npm ERR! A complete log of this run can be found in:
2021-07-19T07:51:28.149Z [err] npm ERR!     C:\Users\weeseong.hew\AppData\Local\npm-cache\_logs\2021-07-19T07_51_28_112Z-debug.log
2021-07-19T07:51:28.200Z rc=1

That is still not correct. Did you follow the instructions for installing on Windows in the node-red docs?

Yeah, I did the exact same step to install the node-red.

That path looks wrong. The .node-red should be a folder on it’s own.

If i'm not wrong, that should be C:\Users\weeseong.hew.node-red\node_modules right? How do I change that?

I’m not a windows user but on the other platforms node-red gets installed in a folder called .node-red that is in the users folder.

On a pi it would be; /home/pi/.node-red
On a Mac it would be /Users/Myname/.node-red

The OP isnt formatting his pasted code and paths as code and the forum is seeing the \ as an escape and messing up the output.

For example, where he wrote

If he used the code format button that would read C:\Users\weeseong.hew\.node-red\node_modules\

@WeeSeong please ensure you post correctly formatted code/logs/paths. it is important to surround your code with three backticks
```
like this
```

You can edit and correct your post by clicking the pencil icon.

See this post for more details - How to share code or flow json

1 Like

Did you fully remove nodejs and npm first, including config files (wherever they are on Windows, I don't know)? I guess that there is still a hangover from when you used npm config set script-shell earlier. I suspect that is now set to an empty string so it can't find the shell command.

Hmmmm now that I've completely reinstalled the thing (not sure how much I have cleared up before reinstallation). Here's the error now when I was trying to install node-red-contrib-modbus:

-----------------------------------------------------------
2021-07-19T07:51:12.490Z Install : node-red-contrib-modbus 5.14.0

2021-07-19T07:51:12.493Z npm.cmd install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production node-red-contrib-modbus@5.14.0
2021-07-19T07:51:28.098Z [err] npm
2021-07-19T07:51:28.098Z [err]  ERR!
2021-07-19T07:51:28.098Z [err]  code ENOENT
2021-07-19T07:51:28.098Z [err] npm ERR! 
2021-07-19T07:51:28.098Z [err] syscall spawn =
2021-07-19T07:51:28.098Z [err] npm
2021-07-19T07:51:28.098Z [err]  ERR! path C:\Users\weeseong.hew\.node-red\node_modules\@serialport\bindings
2021-07-19T07:51:28.098Z [err] npm ERR!
2021-07-19T07:51:28.098Z [err]  errno
2021-07-19T07:51:28.099Z [err]  ENOENT
2021-07-19T07:51:28.103Z [err] npm
2021-07-19T07:51:28.103Z [err]  
2021-07-19T07:51:28.104Z [err] ERR!
2021-07-19T07:51:28.104Z [err]  enoent spawn = ENOENT
2021-07-19T07:51:28.104Z [err] npm ERR! 
2021-07-19T07:51:28.104Z [err] enoent This is related to npm not being able to find a file.
2021-07-19T07:51:28.104Z [err] npm ERR! enoent 
2021-07-19T07:51:28.149Z [err] 
2021-07-19T07:51:28.149Z [err] npm ERR! A complete log of this run can be found in:
2021-07-19T07:51:28.149Z [err] npm ERR!     C:\Users\weeseong.hew\AppData\Local\npm-cache\_logs\2021-07-19T07_51_28_112Z-debug.log
2021-07-19T07:51:28.200Z rc=1

If you try to install a different node do you get a similar error?

Did you find where the config files for npm are and make sure they got removed? It still appears to be trying to run a nothing command. Google found this for me, which might help Where is NPM config file windows?. Alternatively perhaps someone who knows about npm on windows can help.

Oddly enough, when I have to manually reinstall the other nodes for my palette, the error doesn't appear unless its the node-red-contrib-modbus and the node-red-contrib-uibuilder

EDIT: I should probably post this as well

-----------------------------------------------------------
2021-07-19T07:23:54.481Z Install : node-red-contrib-uibuilder 4.0.1

2021-07-19T07:23:58.852Z [err] npm
2021-07-19T07:23:58.852Z [err]  ERR! code ENOENT
2021-07-19T07:23:58.852Z [err] npm ERR! syscall spawn =
2021-07-19T07:23:58.852Z [err] npm ERR! path C:\Users\weeseong.hew\.node-red\node_modules\node-red-contrib-uibuilder
2021-07-19T07:23:58.852Z [err] npm ERR! errno ENOENT
2021-07-19T07:23:58.856Z [err] npm ERR! 
2021-07-19T07:23:58.856Z [err] enoent spawn = ENOENT
2021-07-19T07:23:58.856Z [err] npm ERR! enoent This is related to npm not being able to find a file.
2021-07-19T07:23:58.856Z [err] npm ERR! enoent 
2021-07-19T07:23:58.883Z [err] 
2021-07-19T07:23:58.883Z [err] npm ERR! A complete log of this run can be found in:
2021-07-19T07:23:58.883Z [err] npm ERR!     C:\Users\weeseong.hew\AppData\Local\npm-cache\_logs\2021-07-19T07_23_58_857Z-debug.log
2021-07-19T07:23:58.915Z rc=1

That will likely because most nodes don't need to be built so it doesn't need a command shell. Possibly the easiest fix is to use the npm config command to tell it where the shell command actually is.

Not sure why you have messed with this? The default configuration works just fine.

> npm config get script-shell
null

I've tried that, and it shows something like this:

C:\Users\weeseong.hew>npm config get script-shell
=

That needs to be null or the correct path.

How do I set that? Because it skipped the '=' part so I can't key in anything

No idea, read the docs maybe.

I think you can edit the file by hand. It should be somewhere in the npm docs.