Steps to create a custom node package for offline installation

Hi folks,

I am absolutely not an NPM expert, so I had some trouble to help @bogi in another discussion. He needed to have a package of my custom node to install it in an offline Node-RED system. Don't know if my way of working is complete or solid, but it seemed to work for me. So sharing the steps I have executed to create such an offline package (containing all dependencies):

  1. Since npm pack doesn't seem to include the node dependencies inside the package, I installed the npm-pack-all package globally:

    npm install npm-pack-all
  2. Then I had to install my custom node globally (-g):

    npm install node-red-contrib-ui-svg

    Note that it seems only to work when you install it globally, since only then the dependencies are being installed in the nested node_modules folder:


  3. Navigate to the custom node folder via command line:

    cd C:\Users\Gebruiker\AppData\Roaming\npm\node_modules\node-red-contrib-ui-svg
  4. Build a package from within the custom node folder:

  5. A few seconds later the tgz archive file will be created:


    This tgz file contains a tar file, which in turn contains a directory with ALL the dependent packages:


  6. Now uninstall the global custom node package again, to avoid conflicts/headache afterwards:

    npm uninstall -g node-red-contrib-ui-svg
  7. Test the package, by opening the "Manage palette" of your Node-RED (which doesn't hav the custom node installed yet!), and navigate to the tgz file and upload it:


  8. If everything goes well, the custom node should become available in the palette to use it in your flows:


Hopefully this can help other people with offline installations.


1 Like

Hi Bart - as I replied in another thread - you can use the normal npm pack as long as you add the dependencies to a bundleddependencies section of your package.json - and run npm i locally before running npm pack (which usually I have done while developing a node anyway) . Not ideal if this means you end up creating two versions of your node (one with and one without dependencies) - and of course it doesn't then let npm try to optimise the installed libraries to reduce size - but for offline work it does work.

Hi Dave,
Thanks for sharing that alternative!
I had also seen that `bundleddependencies´ tonight, but I wasn't sure whether that also works for nested dependencies? Suppose my node depends - via bundleddependencies - on package A, but package A depends in turn on another package B. Does this mean that package A also needs to use bundleddependencies for package B? I assume not, because then it would become hopeless to manage the entire dependency tree...

Ah ok, I see now that Bogi also mentioned that same tgz file in that other discussion...

It seems to work for me if I specify the top level other libraries I need. (And run npm install) so they are all loaded locally. That seems to then pack up the sub-dependencies also.

1 Like