Explainer
Why an npm pack tarball still needs internet to import offline
Short answer
npm pack bundles only the target package's own files; its dependencies stay version ranges that npm downloads at install time, so an isolated Node-RED still fails at registry resolution. Give the target approved connectivity, or ship a bundled archive that carries the whole dependency tree and passes an offline install test.
On this page
npm pack did its job; the archive is simply not self-contained. The command packs one package's own files — manifest, node code, documentation — and leaves every dependency as a version range in the manifest, to be downloaded at install time. When Node-RED imports that tarball on a machine with no route to the npm registry, the install unpacks your files, starts resolving those ranges, cannot reach the registry, and aborts. You have two legitimate fixes: give the target an approved connection and install from the palette, or ship a complete offline package that carries the whole dependency tree and makes zero network lookups — provably, not presumably.
What the pack command puts in the archive #
npm pack runs the same file selection as a publish: the manifest, the files the package ships, its README and license, all under one package/ folder inside the tarball. Dependencies are not packed by default — they exist in the archive only as names and version ranges in the manifest. A plain tarball is an order form for a dependency tree, not the tree itself.
For the module you named, the flows-library page for node-red-contrib-ros states that its nodes use roslibjs, the standard JavaScript library for a ROS bridge. So the install needs at least that package plus whatever roslibjs declares in turn, and none of it is inside a plain pack archive.
npm treats a tarball install like any other install: for each declared range it checks the local cache and, on a miss, queries the registry for metadata and the package archive. A controller that has never run the module holds no matching cache entries, so every dependency becomes a network request the isolated target cannot serve.
Where the import actually breaks #
Read the install log and the failure point tells you which problem you have.
| What the log shows | What it means | Where to go |
|---|---|---|
| A DNS or timeout failure such as getaddrinfo EAI_AGAIN, ENOTFOUND or ETIMEDOUT, after your tarball was accepted | npm is resolving dependencies and cannot reach the registry | complete offline package, or approved connectivity |
| ENOTCACHED during an install in offline mode | the cache lacks one specific package; the error names it | add it to the closure and repack |
| A failure while reading the archive itself, before any package name appears | the tarball is malformed or is not a node-module package | rebuild the archive |
On an isolated target the common case is the first row: your archive unpacks cleanly and the process dies one step later, at name resolution. That is the failure behind Node-RED getaddrinfo EAI_AGAIN means DNS, not internet: the target cannot turn the registry's hostname into an address, so nothing downstream runs.
The decision: a connection or a closure #
Commit to one of two routes; there is no third trick.
If policy allows the target an approved egress path, take it: connect the controller through the sanctioned proxy or firewall rule and install the module from the palette manager like any online machine. On controller-class hardware the first attempt usually fails at name resolution; npm EAI_AGAIN DNS resolution fix for an IoT 2000 controller is the network-side checklist for that symptom.
If the target must stay isolated — the normal state of a production cell — the complete offline package is the answer, and it has to be built and tested, never assumed. Commissioning bench online, cell offline? Build on the bench, then run the acceptance test below with the bench's network cable pulled before you deliver the artifact.
Build an archive that needs no registry #
- On a connected preparation machine that matches the target's operating system, CPU architecture and Node.js major version, make an empty folder and run
npm install node-red-contrib-ros. You get the manifest, a lockfile pinning every version, and a populatednode_modules. - Read the closure with
npm ls --all: every line is a package the target will need. Pinning exact versions for offline node installs is the same discipline described in stable Node-RED gateway flows with vendor-pinned nodes. - Make the archive carry the tree: list the module's runtime dependencies under
bundledDependenciesin its manifest, reinstall so the exact tree is present, and runnpm packagain. npm now writes those dependency folders into the tarball, and an install of that tarball takes them from the archive instead of the registry. - If you cannot edit the module, prime npm instead: copy the preparation machine's npm cache to the target and point the account Node-RED runs under at it, with offline mode set in that account's npm configuration file, so any miss fails loudly instead of quietly reaching out. A private package registry on the plant network is the same idea at team scale.
Prove the closure with a count and a test #
A tarball that looks big is not evidence; a count is.
Worked example with illustrative numbers. Suppose npm ls --all reports the module plus 35 dependency packages, 36 packages in total. The plain pack archive holds 1 of the 36, so an isolated importer must fetch 36 − 1 = 35 packages and fails; after bundling, tar -tzf shows 35 package folders under package/node_modules/, matching the lockfile, so the install makes 0 registry lookups. The count is a property of the pinned versions: change the module version or let a dependency float, and the closure size moves with it. If your count lands short, find the unlisted package in the lockfile, add its parent to bundledDependencies, repack, and count again.
Then run the acceptance test on a twin of the target with no network route: upload the archive through the palette — the mechanics are the same as installing a Node-RED node from a local npm package on Windows — and confirm the node appears in the palette and deploys on a test flow. In offline mode an incomplete closure fails fast with an ENOTCACHED error naming the missing package; treat that error as a finding, fix the list, and rerun until the install completes clean.
The folder swap is a separate fault #
The second thing you tried — replacing the app's node-red folder with a prepared directory of flows and node_modules — fails for a different reason. On the ctrlX CORE Node-RED app, a standard Node-RED data directory is not a supported one-to-one replacement: the app layers its own security and integration onto that folder, so the reload rejects it no matter how good your module is. Keep the two jobs apart: modules enter through the palette, online or as the complete archive, and flows move as an editor export imported through the editor menu, never as a folder.
The decision for each case #
- The target may get an approved connection: connect it and install from the palette; that is the intended path and the fastest.
- The target stays isolated: deliver the bundled archive, built on a matching preparation machine and accepted only after the count and the offline install test pass.
- You already built a plain pack archive and it fails offline: stop retrying it — that archive cannot pass; bundle the tree and repack.
- The node installs but the flows are missing: that is the configuration half; import the flow export through the editor and leave the app's data folder alone.
Questions asked
Does npm's prefer-offline setting make the palette install work without internet?
No. Prefer-offline uses the cache when it holds a matching copy, but on any cache miss it still goes to the registry, so an isolated target fails partway through. Offline mode is the honest setting for validation: a miss fails immediately with an ENOTCACHED error that names the missing package, which is exactly the evidence you need to complete the closure.
Can I copy the node_modules folder from the preparation PC to the target instead?
It sometimes runs when the tree is pure JavaScript, but packages with native add-ons are compiled for one operating system, processor architecture and Node ABI, so a copied folder fails on a different target with errors that look like code bugs. Bundling the tree into the archive and passing the isolated install test gives you a version you can defend.
Do bundled archives work for nodes with native add-ons?
Only onto targets that match the preparation machine's operating system, CPU architecture and Node major version, because the compiled binaries travel inside the archive. Any other target needs the dependency's build toolchain or a prebuilt binary for its platform, so check the dependency's install requirements before promising an offline install.
How do I move my flows to the controller after the nodes install?
Export the flows from the editor menu as one JSON file, install every node they use first, then import that file through the same menu on the target. Node credentials are not part of a standard flow export, so re-enter them node by node and test each connection before handing the cell back.


