Can't run NodeJS instance from Node-Red using exec

I'm new to Node-Red and just getting acquainted.

I'm able to use the 'exec' node to run and log some system commands (eg "ls", "ps", whoami"). These work.

Then I tried launching NodeJS to capture the output of a JavaScript script. That didn't work so I tried something very simple: just trying to capture the output of "node --version" or "node --help". This doesn't log anything at all. I can't tell what the problem is. I do know that the user that is running node-red has permissions to run NodeJS.

Note: Providing the full path to the node js binary (in my case /snap/bin/node) doesn't help.
Note 2: I'm aware I can run JS directly in Node-Red using "function" but I'm trying to run an existing script.

How can I see why this command is failing? I appreciate any insights the community can provide on how to debug this.

Node-RED version: v2.1.3
Node.js version: v14.18.1
OS: Ubuntu 20.04.3 LTS

extra input parameters: -v
command: node

Thanks for the response. I should have mentioned that I tried that. Same result: No output at all.

Side note: Other commands that do run successfully seem to accept the parameters in the same field as the command. Eg "ls -al" works fine.

[{"id":"e3e4b46791f23997","type":"exec","z":"c991dbcde03824f2","command":"ls","addpay":"","append":"-al","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":296,"y":690,"wires":[["5c43a95cd8e293d2"],[],[]]},{"id":"93d732623ef2cb40","type":"inject","z":"c991dbcde03824f2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":126,"y":696,"wires":[["e3e4b46791f23997"]]},{"id":"5c43a95cd8e293d2","type":"debug","z":"c991dbcde03824f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":506,"y":678,"wires":[]}]

It might be snap-related. I'm seeing this error message in syslog when trying to run the flow:

Nov 5 18:45:59 ss1 kernel: [77021.759179] audit: type=1400 audit(1636137959.907:184): apparmor="DENIED" operation="file_inherit" profile="/snap/snapd/13640/usr/lib/snapd/snap-confine" pid=24351 comm="snap-confine" family="unix" sock_type="stream" protocol=0 requested_mask="send receive" denied_mask="send receive" addr=none peer_addr=none

running commands blocks apparmor it needs to be configured.

1 Like

Thanks again.

I was able to resolve this by (re)installing node 14 using the provided binary distribution. Then (re)installing node-red via NPM.

(in other words: avoiding snaps completely)

1 Like