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

**URL:** <https://discourse.nodered.org/t/cant-run-nodejs-instance-from-node-red-using-exec/53270>\
**Category:** General\
**Created:** [5 November 2021 18:19 UTC](https://discourse.nodered.org/t/cant-run-nodejs-instance-from-node-red-using-exec/53270 "2021-11-05T18:19:50Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![southsummit](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/southsummit/32/50541_2.png) [@southsummit](https://discourse.nodered.org/u/southsummit)\
**Post date:** [5 November 2021 18:19 UTC](https://discourse.nodered.org/t/cant-run-nodejs-instance-from-node-red-using-exec/53270/1 "2021-11-05T18:19:50Z")

</div>

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.

 ![CleanShot 2021-11-05 at 11.05.00@2x](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/6/462a4ddb65cba68bc16dabebfdc164a45397239a.png)

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

---

<div class="post-metadata">

**Author:** ![RootShell-coder](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rootshell-coder/32/47167_2.png) [@RootShell-coder](https://discourse.nodered.org/u/RootShell-coder)\
**Post date:** [5 November 2021 18:34 UTC](https://discourse.nodered.org/t/cant-run-nodejs-instance-from-node-red-using-exec/53270/2 "2021-11-05T18:34:40Z")

</div>

extra input parameters: -v  
command: node

---

<div class="post-metadata">

**Author:** ![southsummit](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/southsummit/32/50541_2.png) [@southsummit](https://discourse.nodered.org/u/southsummit)\
**Post date:** [5 November 2021 18:38 UTC](https://discourse.nodered.org/t/cant-run-nodejs-instance-from-node-red-using-exec/53270/3 "2021-11-05T18:38:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![RootShell-coder](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rootshell-coder/32/47167_2.png) [@RootShell-coder](https://discourse.nodered.org/u/RootShell-coder)\
**Post date:** [5 November 2021 18:50 UTC](https://discourse.nodered.org/t/cant-run-nodejs-instance-from-node-red-using-exec/53270/4 "2021-11-05T18:50:33Z")

</div>

![Безымянный](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/b/fb8d6cf65b02cce51a0265a19b141c7cb40bf64b.png)

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

**Author:** ![southsummit](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/southsummit/32/50541_2.png) [@southsummit](https://discourse.nodered.org/u/southsummit)\
**Post date:** [5 November 2021 18:50 UTC](https://discourse.nodered.org/t/cant-run-nodejs-instance-from-node-red-using-exec/53270/5 "2021-11-05T18:50:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![RootShell-coder](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/rootshell-coder/32/47167_2.png) [@RootShell-coder](https://discourse.nodered.org/u/RootShell-coder)\
**Post date:** [5 November 2021 18:56 UTC](https://discourse.nodered.org/t/cant-run-nodejs-instance-from-node-red-using-exec/53270/6 "2021-11-05T18:56:50Z")

</div>

running commands blocks apparmor it needs to be configured.

---

<div class="post-metadata">

**Author:** ![southsummit](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/southsummit/32/50541_2.png) [@southsummit](https://discourse.nodered.org/u/southsummit)\
**Post date:** [5 November 2021 19:33 UTC](https://discourse.nodered.org/t/cant-run-nodejs-instance-from-node-red-using-exec/53270/7 "2021-11-05T19:33:01Z")

</div>

Thanks again.

I was able to resolve this by (re)installing node 14 using the provided [binary distribution](https://nodejs.org/en/download/package-manager/). Then (re)installing node-red via NPM.

---

<div class="post-metadata">

**Author:** ![southsummit](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/southsummit/32/50541_2.png) [@southsummit](https://discourse.nodered.org/u/southsummit)\
**Post date:** [5 November 2021 19:33 UTC](https://discourse.nodered.org/t/cant-run-nodejs-instance-from-node-red-using-exec/53270/8 "2021-11-05T19:33:41Z")

</div>

(in other words: avoiding snaps completely)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [4 January 2022 19:34 UTC](https://discourse.nodered.org/t/cant-run-nodejs-instance-from-node-red-using-exec/53270/9 "2022-01-04T19:34:19Z")

</div>

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