***Update***
We published an open source tool for packing Node-RED pallets for offline installation. See https://github.com/boschrexroth/node-packager.
Introduction
In this How-To, a method of bundling npm (Node Package Manager) packages and dependencies to create an offline installation module is explained. This is useful in the case of a ctrlX OS system not having an internet connection, to allow access to the online npm registry. The procedure below is performed inside the ctrlX App Build Environment, but would work on any linux system. An example bundling node-red-contrib-influxdb dependencies is given along with the module itself as a .tgz archive.
Notes
- Nodes that require a native compile will not function with this method. Ex. Node-red-node-sqlite
- This is a development tool and should not be expected to work in all cases. The user should be aware that these packages and tools are not maintained by Bosch Rexroth and may change at any time.
Versions
- NodeJS v20.12.0
- npm v10.5.0
- Node-RED 2.4.0+3.1.0-ctrlx
Build Module Automated
- Install npm & node.js (npm is included with nodejs installation)
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - sudo apt-get install --yes nodejs
WARNING: Ubuntu has an old version in their package manager, so installing via apt-get without specifying a custom repository, or as a snap via the App Build Environment install script, will not allow some of the functionality used in this example.
- Make directory to build package bundle
mkdir packageBundle
- Set working directory to package bundle directory
cd packageBundle
- Add this script to the packageBundle directory.
- Automatically install and bundle node module.
node bundle <package-name>
- This script will generate a .tgz archive capable of offline installation.
Install Module in Node-RED
At this point, the .tgz can be installed in Node-RED without an internet connection.
- Inside the Node-RED flow editor, select "Manage palette" on the sidebar menu.
- In this example, I am using a virtual CORE running on the same system as the client browser. You'll see this warning message when you open the palette manager without an internet connection.
- Select "Install" and then the "Upload module tgz file" button. Browse to the file location and select the bundled module.
- The module should install successfully, along with all dependencies.