IMD SolutionComputing LibraryShop main store

Troubleshooting

Why the Node-RED install script fails at an apt repository error

Edge computing and IIoT Published 6 min read By IMD Solution engineering team

Short answer

An apt refresh runs before the installer touches Node.js, and one failing source makes it exit non-zero, so the run stops before its own runtime and npm are ever installed. The blank npm in the final Versions line is a step that never happened, not a broken npm. Update and upgrade the system, repair any source that still errors, then rerun the script and confirm both version fields print.

On this page
  1. Read the log in execution order, not by its last line
  2. Why the failed refresh leaves npm blank
  3. Repair the sources, upgrade, then rerun
  4. Working the Debian 9 armhf log: one failed source against zero tolerated
  5. The acceptance check before you trust the install
  6. Questions asked

The failure is not npm. The installer refreshes the package index with apt before it installs its own Node.js runtime, and in this log a third-party source answered that refresh with a certificate error and no Release file. apt exits non-zero when a single source fails, the script prints Error executing command, exiting, and the runtime it came to install is never put in place. The final Versions: node:v8.11.1 npm: line reports only what the machine had left: an old distribution Node and no npm. The fix is at the package-manager level: update and upgrade the system, repair or remove any source that still errors, rerun the script, and require both version fields to print.

Read the log in execution order, not by its last line #

The last line is a symptom. The cause is the first operation that failed, and the log names it earlier. Work through the messages in the order they appear:

Message in the log What it tells you What to do
WARNING: apt does not have a stable CLI interface. Use with caution in scripts. apt's standard notice to scripts; it appears on healthy runs too Keep reading; this is not the failure
An Err: line naming a source, with server certificate verification failed The TLS check against that repository failed Check the clock, then the trust chain, then the source entry
E: The repository ... does no longer have a Release file apt could not fetch usable metadata for that source The same source as the Err: line; repair it or remove it
Error executing command, exiting The script's own exit line: a command returned non-zero and the run stopped Treat everything the run promised afterward as not done
Versions: node:... npm: with the npm field empty The probe found a Node binary and no npm Fix the refresh; do not chase npm

One detail decides where you spend your time: the repository named in the error is not one the installer needs. The refresh walks every configured source, so an unrelated remote-support repository can stop a Node-RED install cold. That is why the repair is done in apt, not inside Node-RED.

Why the failed refresh leaves npm blank #

The script refreshes the index, then configures a Node.js package source, installs Node.js and npm, installs Node-RED, and reports versions. The first command that returns non-zero ends the run. When the refresh dies on a third-party source, the run finishes without the runtime it came to install, and the closing line can only report what the machine already had.

On this Debian 9 armhf image the distribution's nodejs package provides the node binary and no npm — hence a printed node version and an empty npm field. Two things follow. First, npm is not broken; it was never installed by this run. Second, the reported runtime is outside Node-RED's support set: the project supports the Maintenance and Active LTS lines of Node.js and currently recommends 24.x, and a Node 8 binary is in neither line. Even a hand-installed npm would leave an unsupported runtime, so the installer must be allowed to replace the runtime — which the failed refresh prevented.

Repair the sources, upgrade, then rerun #

  1. Back up what runs the plant. Copy the folder Node-RED runs from, under the account that owns it — flows, credentials and settings — and note how the service is started. The steps below change operating-system packages, and the upgrade touches the whole image.
  2. Check the clock before anything else. Compare the device's date with a trusted clock; a date wrong by months or years fails every certificate check. The install log's own start line shows the time the device believed when it ran.
  3. Run sudo apt update on its own and read every Err: line. Each names one failing source. In the case worked below, a single third-party source failed while the rest refreshed.
  4. Run sudo apt upgrade, then repeat the refresh and read it again. The upgrade also refreshes the certificate and CA packages, and in the worked case it cleared the error entirely.
  5. If a source still fails, decide whether you need its software. If it is needed, get the current repository entry from that software's supplier and replace the stale line in /etc/apt/sources.list or the file that defines the source. If it is not needed, disable the entry through your normal change control.
  6. Rerun the official install script and read the new log end to end.

Do not force the refresh through by marking the source trusted or switching off certificate verification: that tells apt to accept unauthenticated packages on a machine that executes your flows. Repair the entry or remove it.

Working the Debian 9 armhf log: one failed source against zero tolerated #

The inputs #

  • Failed sources reported by the refresh: 1 — one Err: line, numbered 5 in the output (from the install log).
  • Failed sources the script tolerates: 0 — its exit line fires on the first non-zero command (from the same log).
  • Device time at start: Sat 12 Dec 2020 — plausible, so the clock check passes (from the log's start line).
  • Runtime found afterward: node v8.11.1 and no npm — the distribution's build for this image (from the final Versions line).
  • Support set: the Maintenance and Active LTS lines of Node.js, currently recommending 24.x (from the project's version documentation).
  • Packages pending at upgrade: 333 (from the same install log).

The rule #

apt exits non-zero when one or more configured sources fail, even if every other source refreshes cleanly. The installer stops at the first non-zero command, so its supported runtime and npm arrive only after a clean refresh.

The arithmetic #

  • Failed sources over tolerance: 1 − 0 = 1, so the refresh exits non-zero and the run stops inside its package setup.
  • Supported runtimes and npm installed by the script in this state: 0 — the only Node left on the machine is the distribution's build, which ships without npm.
  • Support gap of that leftover runtime: recommended major 24 − installed major 8 = 16 major versions, and major 8 sits below the Maintenance LTS line, so a patched-in npm would not make it supported.
  • System change applied before the retry: 333 packages upgraded, after which the same repository refreshed without the certificate error.

The result #

With the refresh clean, the rerun installed the supported runtime and both version fields printed. That is the whole fix: no npm surgery, no manual Node install.

The decision #

Rerun the script only when sudo apt update finishes without an Err: line — the tolerance is zero failed sources, and one is enough to reproduce the blank npm. Accept the closing line only when the node major is a Maintenance or Active LTS release and the npm field is filled; anything else means a step was skipped again.

The acceptance check before you trust the install #

  • A standalone sudo apt update runs to the end without an error line.
  • Both fields of the final Versions line are filled, and the node major is inside the supported LTS window.
  • The Node-RED service starts and the editor loads the existing flows.
  • Before rerunning on any other box, confirm which Linux release and processor architecture it runs, the checks covered in identify the Linux base before installing Node-RED natively, because the package sources involved depend on both.
  • If a later run fails while npm talks to the registry with a getaddrinfo EAI_AGAIN error, that is name resolution, a different fault — see Node-RED getaddrinfo EAI_AGAIN means DNS, not internet.

Questions asked

How do I see which Node.js version apt would pick before rerunning the script?

Ask apt before rerunning: the policy listing for the nodejs package shows the installed version and the candidate version, with the source each comes from. Before the installer adds its own package source, the candidate can only be the distribution's build, which is how an old runtime ends up on the machine. After a successful run the candidate should come from the installer's source instead.

apt prints 'server certificate verification failed' — what do I check first?

The clock, then trust. A device date that is wrong by months or years fails every TLS check, so compare it with a trusted clock before anything else. If the time is right, a full system upgrade refreshes the CA certificate package. Networks that inspect TLS also require the inspection root certificate on the device, which your network administrator provides. Leave verification switched on.

Can I mark the failing repository as trusted so the installer gets past it?

No. A trusted flag or disabled verification tells apt to accept that source's packages without authenticating them, on a machine that runs your flows. The error means the source's metadata could not be validated. Get the current entry from the software's supplier, or disable the entry if the software is no longer needed, and refresh again.

Why not install Node-RED from the distribution's own package instead of the script?

Because distribution packages lag behind the project. The Node-RED package in Raspberry Pi OS has drawn in Node.js 12, a release the project no longer supports. The install script exists to place a runtime inside the supported LTS window on the machine, so repairing the package sources and rerunning the script is the supported route.

The install now completes, but the editor freezes after I edit a node. Same fault?

No. Once both versions print and the service runs, package installation is finished. Freezes after editing a node, or a duplicated node when one is dragged, point at the browser session; the default browser on small industrial controllers is limited. Open the editor in a current desktop browser on another computer — 192.168.1.100 on port 1880 as an example, with your device's own address — and repeat the same edit.

Keep reading

  • Troubleshooting

    Fix npm E502 when installing Node-RED nodes behind a proxy

    npm error code E502 on a palette install means an answering hop could not resolve or connect onward to the registry host, even when a generic HTTP check passes. Work the failure upstream from the proxy: confirm the proxy process, match the device's proxy address and mode, check the firewall rule, then verify outbound TCP 443 to registry.npmjs.org. Treat an App Unavailable editor as a missing localhost exception, a separate fault.

    Edge computing and IIoT

  • How-to

    Install Node-RED Natively on a Linux Edge Computer

    Install Node-RED directly on the Debian-based edge computer rather than in Docker: give the login account sudo, install build-essential, git and curl, then run Node-RED's official Debian install script and start the runtime without the -v flag. The script installs Node.js, npm and Node-RED and registers a systemd service, so the runtime also starts at boot.

    Edge computing and IIoT

  • Troubleshooting

    Node-RED crashes after a node install: safe mode and rollback

    The fatal log line is the one reading Uncaught Exception with a stack trace; palette warnings above it are survived. Stop the nodered systemd unit, start node-red with --safe so the editor opens with flows stopped, then roll the package the stack names back to its previous release with npm install --save-exact and confirm the pin with npm ls before you let the flows run.

    Edge computing and IIoT

Why an MQTT receive script updates only the first JSON attribute