Error: Cannot find module '/home/$USER/red.js'

Hi,

I am a Node-RED user and I use it regularly, although I haven't been able to access Node-RED for a few days, since I get the following error:

> de febr. 17 09:57:53 industrialshields Node-RED[15788]: Error: Cannot find module '/home/qmf/red.js'
> de febr. 17 09:57:53 industrialshields Node-RED[15788]:     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
> de febr. 17 09:57:53 industrialshields Node-RED[15788]:     at Function.Module._load (internal/modules/cjs/loader.js:667:27)
> de febr. 17 09:57:53 industrialshields Node-RED[15788]:     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
> de febr. 17 09:57:53 industrialshields Node-RED[15788]:     at internal/main/run_main_module.js:17:47 {
> de febr. 17 09:57:53 industrialshields Node-RED[15788]:   code: 'MODULE_NOT_FOUND',
> de febr. 17 09:57:53 industrialshields Node-RED[15788]:   requireStack: []
> de febr. 17 09:57:53 industrialshields Node-RED[15788]: }
> de febr. 17 09:57:53 industrialshields systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE
> de febr. 17 09:57:53 industrialshields systemd[1]: nodered.service: Failed with result 'exit-code'.
> de febr. 17 09:58:13 industrialshields systemd[1]: nodered.service: Scheduled restart job, restart counter is at 1.
> de febr. 17 09:58:13 industrialshields systemd[1]: Stopped Node-RED graphical event wiring tool.
> de febr. 17 09:58:13 industrialshields systemd[1]: Started Node-RED graphical event wiring tool.
> de febr. 17 09:58:13 industrialshields Node-RED[15808]: internal/modules/cjs/loader.js:818
> de febr. 17 09:58:13 industrialshields Node-RED[15808]:   throw err;
> de febr. 17 09:58:13 industrialshields Node-RED[15808]:   ^
> de febr. 17 09:58:13 industrialshields Node-RED[15808]: Error: Cannot find module '/home/qmf/red.js'
> de febr. 17 09:58:13 industrialshields Node-RED[15808]:     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
> de febr. 17 09:58:13 industrialshields Node-RED[15808]:     at Function.Module._load (internal/modules/cjs/loader.js:667:27)
> de febr. 17 09:58:13 industrialshields Node-RED[15808]:     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
> de febr. 17 09:58:13 industrialshields Node-RED[15808]:     at internal/main/run_main_module.js:17:47 {
> de febr. 17 09:58:13 industrialshields Node-RED[15808]:   code: 'MODULE_NOT_FOUND',
> de febr. 17 09:58:13 industrialshields Node-RED[15808]:   requireStack: []
> de febr. 17 09:58:13 industrialshields Node-RED[15808]: }
> de febr. 17 09:58:13 industrialshields systemd[1]: nodered.service: Main process exited, code=exited, status=1/FAILURE
> de febr. 17 09:58:13 industrialshields systemd[1]: nodered.service: Failed with result 'exit-code'.

And when I "sudo systemctl status nodered.service", I get that the service is constantly activating.

Anyways, I can run 'node-red' and it works. So, it is the service that it doesn't, but that is what I want.

I don't know if it's a coincidence or not, but these days I've updated to version 2.2, and I've also installed FlowForge on my computer.

Could you help me please?

Thank you,

Q.

This is also what I see when I run:
sudo systemctl status nodered

● nodered.service - Node-RED graphical event wiring tool
     Loaded: loaded (/lib/systemd/system/nodered.service; disabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: exit-code) since Thu 2022-02-17 11:06:54 CET; 3s ago
       Docs: http://nodered.org/docs/hardware/raspberrypi.html
    Process: 20636 ExecStart=/usr/bin/env node $NODE_OPTIONS red.js $NODE_RED_OPTIONS (code=exited, status=1/FAILURE)
   Main PID: 20636 (code=exited, status=1/FAILURE)

If it helps!

What h/w and OS are you using and how did you install node-red?

Post the log from before the error you show, starting from the Welcome to node-red message. Depending how you installed node red you may be able to get the log in a terminal using
node-red-stop
node-red-start

Thank you Colin, but finally I solved it by going to the /lib/systemd/system/nodered.service and commenting the

#ExecStart=/usr/bin/env node $NODE_OPTIONS red.js $NODE_RED_OPTIONS

and discommenting the:
ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS

Thank you anyways!

Had you previously changed it? What you have now is the default file contents.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.