BundleNPMTeaser.png

Bundle npm Packages for Offline Node-RED Installation

Sgilk
Contributor
***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
  1. 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.

  2. Make directory to build package bundle
    mkdir packageBundle​​
  3. Set working directory to package bundle directory
    cd packageBundle​
  4. Add this script to the packageBundle directory.
  5. Automatically install and bundle node module.
    node bundle <package-name>
  6. 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.

  1. Inside the Node-RED flow editor, select "Manage palette" on the sidebar menu.

    Manage paletteManage palette
  2. 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.

    Failed to load nodes errorFailed to load nodes error
  3. Select "Install" and then the "Upload module tgz file" button. Browse to the file location and select the bundled module.

    Upload moduleUpload module
  4. The module should install successfully, along with all dependencies.
Sgilk
Sgilk
Hello, my name is Sam and I am a Software Applications Engineer supporting ctrlX Automation. Feel free to reach out if you have any questions!
Must Read
Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist