Unable to exec npx commands since Node-Red update

Hello,

I had an exec node that calls npm run tydom-client request /configs/file --username XXXXXX --password XXXXXX
I worked well until I upgraded Node-Red from version 15 to version 17. But now it runs indefinitely.

The tydom-client is still available on npm and I added it to the npm_packages in the config. But I cannot see it explicitly installed in the logs. I don’t know if it’s normal.

Do someone know what could have changed in Node-Red that makes my exec node running indefinitely?

During version 16 the file locations moved. My guess would be that /configs/file is not where it used to be, or the file path needs to change to something else.

Hello, thanks for your answer

I should have pointed out that /configs/file is a path to a web service, not to a file :wink:

But perhaps this change in file locations affects the way I have to define my exec node?

npm loads early in the start sequence. The logs only disply the last x amount of lines.

Go to addon page, restart nodered, go directly to the log tab and refresh every few seconds to catch were the npm load sequence is.

If it’s not showing in that section, it’s not being loaded.

yes but there is nothing concerning tydom-client in the logs, as you can see:

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service base-addon-banner: starting

-----------------------------------------------------------
 Add-on: Node-RED
 Flow-based programming for the Internet of Things
-----------------------------------------------------------
 Add-on version: 17.0.3
 You are running the latest version of this add-on.
 System: Home Assistant OS 11.4  (aarch64 / raspberrypi3-64)
 Home Assistant Core: 2024.1.5
 Home Assistant Supervisor: 2023.12.1
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
Log level is set to DEBUG
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-nginx: starting
s6-rc: info: service init-customizations: starting
[12:03:39] INFO: Starting installation of custom NPM/Node-RED packages...
s6-rc: info: service init-nginx successfully started
npm WARN config optional Use `--omit=optional` to exclude optional dependencies, or
npm WARN config `--include=optional` to include them.
npm WARN config 
npm WARN config     Default value does install optional deps unless otherwise omitted.
npm WARN config only Use `--omit=dev` to omit dev dependencies from the install.

added 35 packages, and audited 621 packages in 41s

107 packages are looking for funding
  run `npm fund` for details

13 vulnerabilities (11 moderate, 2 critical)

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
npm notice 
npm notice New minor version of npm available! 10.2.3 -> 10.3.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.3.0>
npm notice Run `npm install -g [email protected]` to update!
npm notice 

added 28 packages, and audited 649 packages in 36s

111 packages are looking for funding
  run `npm fund` for details

13 vulnerabilities (11 moderate, 2 critical)

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
s6-rc: info: service init-customizations successfully started
s6-rc: info: service init-nodered: starting

I was able to get the package installed on my instance. I didn’t test it though. In your config page of the addon, change the log level to trace. If the option for log is not shown, edit in yaml mode and add log_level: trace at the top.

Restart, let everything load, then execute the flow. Look at the log to see if you can catch an error. If not you maybe able to execute the code through a function. You can specify modules to use. It should also be easier to find out exactly why it’s failing.

If your stuck try the actual node red forums, issues like this, modules not related to HA is more suited to the NR forum.

Hi, sorry for the late answer, but I did not find a way to get all the TRACE logs.
When viewing logs from the UI I don’t get much lines.
When using ha host logs --identifier myNodeRedId -f I see the full logs but it is too speed so I cannot see anything special when installing packages. And I cannot scroll up
If I execute ha host logs --identifier myNodeRedId > file.txt I don’t get the full logs…

So here are the logs I was able to get

NB: Sorry I didn’t see how to upload a file

        end
s6-rc: info: service init-nginx successfully started
npm WARN config optional Use `--omit=optional` to exclude optional dependencies, or
npm WARN config `--include=optional` to include them.
npm WARN config 
npm WARN config     Default value does install optional deps unless otherwise omitted.
npm WARN config only Use `--omit=dev` to omit dev dependencies from the install.

added 35 packages, and audited 621 packages in 48s

107 packages are looking for funding
  run `npm fund` for details

13 vulnerabilities (11 moderate, 2 critical)

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
npm notice 
npm notice New minor version of npm available! 10.2.3 -> 10.4.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.4.0>
npm notice Run `npm install -g [email protected]` to update!
npm notice 
[11:27:03] TRACE: bashio::config.has_value: init_commands
[11:27:03] TRACE: bashio::config: init_commands
[11:27:03] TRACE: bashio::addon.config
[11:27:03] TRACE: bashio::cache.exists: addons.self.options.config
[11:27:03] TRACE: bashio::fs.file_exists: /tmp/.bashio/addons.self.options.config.cache
[11:27:03] TRACE: bashio::cache.get: addons.self.options.config
[11:27:03] TRACE: bashio::cache.exists: addons.self.options.config
[11:27:03] TRACE: bashio::fs.file_exists: /tmp/.bashio/addons.self.options.config.cache
[11:27:03] TRACE: bashio::jq: {"theme":"default","http_node":{"username":"nodered","password":"**********"},"http_static":{"username":"nodered","password":"**********"},"ssl":true,"certfile":"fullchain.pem","keyfile":"privkey.pem","system_packages":[],"npm_packages":["tydom-client"],"init_commands":[],"credential_secret":"**********","log_level":"trace"} if (.init_commands == null) then
            null
        elif (.init_commands | type == "string") then
            .init_commands // empty
        elif (.init_commands | type == "boolean") then
            .init_commands // false
        elif (.init_commands | type == "array") then
            if (.init_commands == []) then
                empty
            else
                .init_commands[]
            end
        elif (.init_commands | type == "object") then
            if (.init_commands == {}) then
                empty
            else
                .init_commands
            end
        else
            .init_commands
        end
[11:27:03] TRACE: bashio::var.has_value: 
s6-rc: info: service init-customizations successfully started
s6-rc: info: service init-nodered: starting
[11:27:04] TRACE: bashio::fs.file_exists: /config/settings.js
[11:27:04] TRACE: bashio::fs.file_exists: /config/settings.js
[11:27:04] TRACE: bashio::addon.port 80
[11:27:04] TRACE: bashio::addons self addons.self.network.80-tcp .network["80/tcp"] // empty
[11:27:04] TRACE: bashio::cache.exists: addons.self.network.80-tcp
[11:27:04] TRACE: bashio::fs.file_exists: /tmp/.bashio/addons.self.network.80-tcp.cache
[11:27:04] TRACE: bashio::cache.get: addons.self.network.80-tcp
[11:27:04] TRACE: bashio::cache.exists: addons.self.network.80-tcp
[11:27:04] TRACE: bashio::fs.file_exists: /tmp/.bashio/addons.self.network.80-tcp.cache
[11:27:04] TRACE: bashio::var.has_value: 1880
[11:27:04] TRACE: bashio::config.true: ssl
[11:27:04] TRACE: bashio::config: ssl
[11:27:04] TRACE: bashio::addon.config
[11:27:04] TRACE: bashio::cache.exists: addons.self.options.config
[11:27:04] TRACE: bashio::fs.file_exists: /tmp/.bashio/addons.self.options.config.cache
[11:27:04] TRACE: bashio::cache.get: addons.self.options.config
[11:27:04] TRACE: bashio::cache.exists: addons.self.options.config
[11:27:04] TRACE: bashio::fs.file_exists: /tmp/.bashio/addons.self.options.config.cache
[11:27:04] TRACE: bashio::jq: {"theme":"default","http_node":{"username":"nodered","password":"**********"},"http_static":{"username":"nodered","password":"**********"},"ssl":true,"certfile":"fullchain.pem","keyfile":"privkey.pem","system_packages":[],"npm_packages":["tydom-client"],"init_commands":[],"credential_secret":"**********","log_level":"trace"} if (.ssl == null) then
            null
        elif (.ssl | type == "string") then
            .ssl // empty
        elif (.ssl | type == "boolean") then
            .ssl // false
        elif (.ssl | type == "array") then
            if (.ssl == []) then
                empty
            else
                .ssl[]
            end
        elif (.ssl | type == "object") then
            if (.ssl == {}) then
                empty
            else
                .ssl
            end
        else
            .ssl
        end
[11:27:04] TRACE: bashio::var.true: true
[11:27:04] TRACE: bashio::fs.file_exists: /config/package.json

...

s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
[11:27:35] TRACE: bashio::config.exists: max_old_space_size
[11:27:35] TRACE: bashio::net.wait_for 46836 localhost 300
[11:27:35] TRACE: bashio::config: max_old_space_size
[11:27:35] TRACE: bashio::addon.config
[11:27:35] TRACE: bashio::cache.exists: addons.self.options.config
[11:27:35] TRACE: bashio::fs.file_exists: /tmp/.bashio/addons.self.options.config.cache
[11:27:35] TRACE: bashio::cache.get: addons.self.options.config
[11:27:35] TRACE: bashio::cache.exists: addons.self.options.config
[11:27:35] TRACE: bashio::fs.file_exists: /tmp/.bashio/addons.self.options.config.cache
[11:27:35] TRACE: bashio::jq: {"theme":"default","http_node":{"username":"nodered","password":"**********"},"http_static":{"username":"nodered","password":"**********"},"ssl":true,"certfile":"fullchain.pem","keyfile":"privkey.pem","system_packages":[],"npm_packages":["tydom-client"],"init_commands":[],"credential_secret":"**********","log_level":"trace"} if (.max_old_space_size == null) then
            null
        elif (.max_old_space_size | type == "string") then
            .max_old_space_size // empty
        elif (.max_old_space_size | type == "boolean") then
            .max_old_space_size // false
        elif (.max_old_space_size | type == "array") then
            if (.max_old_space_size == []) then
                empty
            else
                .max_old_space_size[]
            end
        elif (.max_old_space_size | type == "object") then
            if (.max_old_space_size == {}) then
                empty
            else
                .max_old_space_size
            end
        else
            .max_old_space_size
        end
[11:27:35] TRACE: bashio::config.true: safe_mode
[11:27:35] TRACE: bashio::config: safe_mode
[11:27:35] TRACE: bashio::addon.config
[11:27:35] TRACE: bashio::cache.exists: addons.self.options.config
[11:27:36] TRACE: bashio::fs.file_exists: /tmp/.bashio/addons.self.options.config.cache
[11:27:36] TRACE: bashio::cache.get: addons.self.options.config
[11:27:36] TRACE: bashio::cache.exists: addons.self.options.config
[11:27:36] TRACE: bashio::fs.file_exists: /tmp/.bashio/addons.self.options.config.cache
[11:27:36] TRACE: bashio::jq: {"theme":"default","http_node":{"username":"nodered","password":"**********"},"http_static":{"username":"nodered","password":"**********"},"ssl":true,"certfile":"fullchain.pem","keyfile":"privkey.pem","system_packages":[],"npm_packages":["tydom-client"],"init_commands":[],"credential_secret":"**********","log_level":"trace"} if (.safe_mode == null) then
            null
        elif (.safe_mode | type == "string") then
            .safe_mode // empty
        elif (.safe_mode | type == "boolean") then
            .safe_mode // false
        elif (.safe_mode | type == "array") then
            if (.safe_mode == []) then
                empty
            else
                .safe_mode[]
            end
        elif (.safe_mode | type == "object") then
            if (.safe_mode == {}) then
                empty
            else
                .safe_mode
            end
        else
            .safe_mode
        end
[11:27:36] TRACE: bashio::var.true: null
[11:27:36] INFO: Starting Node-RED...

> start
> node $NODE_OPTIONS node_modules/node-red/red.js --settings /etc/node-red/config.js

27 Jan 11:27:55 - [info] 

Welcome to Node-RED
===================

27 Jan 11:27:55 - [info] Node-RED version: v3.1.3
27 Jan 11:27:55 - [info] Node.js  version: v18.19.0
27 Jan 11:27:55 - [info] Linux 6.1.63-haos-raspi arm64 LE
27 Jan 11:28:21 - [info] Loading palette nodes
27 Jan 11:28:26 - [debug] Module: @node-red-contrib-themes/theme-collection 3.1.8 /opt/node_modules/@node-red-contrib-themes/theme-collection
27 Jan 11:28:26 - [debug] Module: node-red-contrib-bigtimer 2.8.5 /opt/node_modules/node-red-contrib-bigtimer
27 Jan 11:28:26 - [debug] Module: node-red-contrib-cast 0.2.17 /opt/node_modules/node-red-contrib-cast
27 Jan 11:28:26 - [debug] Module: node-red-contrib-counter 0.1.6 /opt/node_modules/node-red-contrib-counter
27 Jan 11:28:27 - [debug] Module: node-red-contrib-home-assistant-websocket 0.62.3 /opt/node_modules/node-red-contrib-home-assistant-websocket
27 Jan 11:28:27 - [debug] Module: node-red-contrib-influxdb 0.7.0 /opt/node_modules/node-red-contrib-influxdb
27 Jan 11:28:27 - [debug] Module: node-red-contrib-interval-length 0.0.6 /opt/node_modules/node-red-contrib-interval-length
27 Jan 11:28:27 - [debug] Module: node-red-contrib-modbus 5.27.2 /opt/node_modules/node-red-contrib-modbus
27 Jan 11:28:27 - [debug] Module: node-red-contrib-moment 5.0.0 /opt/node_modules/node-red-contrib-moment
27 Jan 11:28:27 - [debug] Module: node-red-contrib-persistent-fsm 1.2.1 /opt/node_modules/node-red-contrib-persistent-fsm
27 Jan 11:28:27 - [debug] Module: node-red-contrib-sunevents 3.1.1 /opt/node_modules/node-red-contrib-sunevents
27 Jan 11:28:27 - [debug] Module: node-red-contrib-time-range-switch 1.2.0 /opt/node_modules/node-red-contrib-time-range-switch
27 Jan 11:28:27 - [debug] Module: node-red-dashboard 3.6.2 /opt/node_modules/node-red-dashboard
27 Jan 11:28:27 - [debug] Module: node-red-node-base64 0.3.0 /opt/node_modules/node-red-node-base64
27 Jan 11:28:27 - [debug] Module: node-red-node-email 2.1.0 /opt/node_modules/node-red-node-email
27 Jan 11:28:27 - [debug] Module: node-red-node-feedparser 0.3.0 /opt/node_modules/node-red-node-feedparser
27 Jan 11:28:27 - [debug] Module: node-red-node-ping 0.3.3 /opt/node_modules/node-red-node-ping
27 Jan 11:28:27 - [debug] Module: node-red-node-random 0.4.1 /opt/node_modules/node-red-node-random
27 Jan 11:28:27 - [debug] Module: node-red-node-serialport 2.0.2 /opt/node_modules/node-red-node-serialport
27 Jan 11:28:27 - [debug] Module: node-red-node-smooth 0.1.2 /opt/node_modules/node-red-node-smooth
27 Jan 11:28:27 - [debug] Module: node-red-node-suncalc 1.1.0 /opt/node_modules/node-red-node-suncalc
27 Jan 11:28:27 - [debug] Module: node-red-node-twitter 1.2.0 /opt/node_modules/node-red-node-twitter
27 Jan 11:28:29 - [info] Node-RED Contrib Theme Collection version: v3.1.8
27 Jan 11:29:25 - [info] Dashboard version 3.6.2 started at /endpoint/ui

When it gets to the end and node red has started, the quoted text above. Trigger the flow with the problem node. Come back to the log and refresh. It should log the flow being executed including any results.

This is where you need to set it to trace.

There are no TRACE logs when executing the node (but there are when deploying it)

Here are the logs when I try to run the command without double quotes:

28 Jan 15:47:37 - [debug] [exec:Call Config Info] npm run tydom-client request /configs/file --username ********** --password **********
28 Jan 15:47:57 - [debug] [exec:Call Config Info] error:Error: Command failed: npm run tydom-client request /configs/file --username ********** --password **********

And with double quotes:

28 Jan 15:49:35 - [debug] [exec:Call Config Info] "npm run tydom-client request /configs/file --username ********** --password **********"
28 Jan 15:49:35 - [debug] [exec:Call Config Info] error:Error: Command failed: "npm run tydom-client request /configs/file --username ********** --password **********"
/bin/bash: line 1: npm run tydom-client request /configs/file --username ********** --password **********: No such file or directory

Here are the logs when deploying flows:

28 Jan 15:49:10 - [info] Updated flows
28 Jan 15:49:10 - [info] Starting modified flows
28 Jan 15:49:10 - [trace] [flow:global] start flow [global]
28 Jan 15:49:10 - [trace] [flow:global] ------------------|--------------|-----------------
28 Jan 15:49:10 - [trace] [flow:global]  id               | type         | alias
28 Jan 15:49:10 - [trace] [flow:global] ------------------|--------------|-----------------
28 Jan 15:49:10 - [trace] [flow:global]  ad57cdb9.7f9b    | server       | 
28 Jan 15:49:10 - [trace] [flow:global]  3a5a53bfaae7c271 | ui_group     | 
28 Jan 15:49:10 - [trace] [flow:global]  d4cf768e634d6f4d | websocket-client | 
28 Jan 15:49:10 - [trace] [flow:global]  3a985981148aa4f0 | tls-config   | 
28 Jan 15:49:10 - [trace] [flow:global]  6dbfa1a771fcc52c | ha-device-config | 
28 Jan 15:49:10 - [trace] [flow:global]  0c56c1bbb2744e00 | ha-entity-config | 
28 Jan 15:49:10 - [trace] [flow:global] ------------------|--------------|-----------------
28 Jan 15:49:10 - [trace] [flow:f3c120a84b15ddba] start flow [f3c120a84b15ddba]
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba] ------------------|--------------|-----------------
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  id               | type         | alias
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba] ------------------|--------------|-----------------
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  e0c6145e05de7cc1 | http request | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  a7c5b7d73b86ded9 | debug        | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  1b9c31fd6710b88d | inject       | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  148e19a9d8e01376 | debug        | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  112520eb08063fbc | function     | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  f48f4a5cf6047312 | debug        | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  118b9b1f59acb838 | function     | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  46360668895b329c | exec         | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  4a15566667b4cdf8 | function     | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  be17ea966cef2891 | debug        | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  fda64de9c128bc90 | inject       |
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  6fb4383d6a3c0c2b | ui_dropdown  | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  2102bb993347bf5a | ha-sensor    | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  59257c5c4e238eb9 | inject       | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  9a6564fd9ec0f604 | debug        | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  940d07e60b6fe3f4 | inject       | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  eca7048450e8a6d3 | exec         | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  a33af9f6c4d8d08e | debug        | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  144801a88a60c1f5 | debug        | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  8eee8c4be1532a75 | function     | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  681e6852b1112ee3 | debug        | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  6171e50244ca68bb | exec         | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  37912c458f96389c | function     | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  0b502187e12bcc2d | debug        | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  1e459a6ffbd8652c | inject       | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  1890037284da232d | ui_dropdown  | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  daff7882a6621f35 | function     | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  47e76c5f9572b654 | debug        | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  2442533d6978318e | inject       | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  20e7fb6472e87853 | debug        | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  bb8036ad13befe89 | function     | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba]  daaf2435b4db9b43 | inject       | 
28 Jan 15:49:11 - [trace] [flow:f3c120a84b15ddba] ------------------|--------------|-----------------
28 Jan 15:49:11 - [trace] runtime event: {"id":"runtime-state","payload":{"state":"start","deploy":true},"retain":true}
28 Jan 15:49:11 - [info] Started modified flows
28 Jan 15:49:11 - [trace] runtime event: {"id":"runtime-deploy","payload":{"revision":"e76becc8d7512bebe1e897c6722dd120"},"retain":true}

EDIT : here is the part of logs that concerns installation of custom NPM packages. If see nothing special

I have uninstalled and reinstalled node-red, but still the same problem

Do someone have an idea?

Nodered has it’s own forum. You may have better luck finding an answer. Post what you wrote in the first post and message 9. Don’t link back to the post, post the actual content.

Hello,
Thanks @Mikefila but I made another try and Node-Red is not the problem here, it’s the addon.
Indeed, I tried to install Node-Red on my computer and added an exec node with npx myPackage some other params instead of npm run myPackage some other params, and it works correctly without having to add myPackage to the palette.
This npx command does not work on the node-red addon in Home Assistant. So I guess the error is caused by the file location that has changed between versions 15 and 17, as @Biscuit suggested.

But I don’t know what to do / what to try then