How to install node offline using node-red Admin API

I am trying to install nodes in node-red without internet (offline). I have npm pack file (.tgz) and trying to install use admin method "/nodes" POST (POST /nodes : Node-RED), but "I am getting module not found error".

I tried few things :

  1. I extracted the .tgz file and gave path to package.json of nodes.
  2. I tried to give the path of dir where the package.json is present.
  3. I didn't extract it and gave path of .tgz file. (I know it will not work according to doc)

can anyone please suggest what I am doing wrong here or any other alternative method ?

Welcome to the forums @jayashree.

I think you mileage is going to vary.

You can install NPM packages with no internet, really easily:

image

The problem you will face, is when those packages have dependencies, NPM will try and pull them down from the NPM registry.

You options are:

  • Go for a dependency walk (Good Luck)
  • Install all nodes you need, on a machine WITH internet, then move the node_modules folder over, but if the platform architectures are different - you going to have issues with Native modules, you can rebuild them however, so maybe not so much of a problem.

@marcus-j-davies the npm pack file will contain everything needed.

@jayashree You need to include the file contents in the HTTP post request under a property called 'tarball':

The following curl command does the job.

curl -F tarball=@node-red-node-random-0.4.1.tgz http://localhost:1880/nodes
1 Like

Hi @knolleary

So if I pull a tgz from NPM, example: https://registry.npmjs.org/node-red/-/node-red-3.0.2.tgz

The tgz also includes all dependencies required by node-red-3.0.2, and therefore will not need to fetch anything further from NPM?

EDIT
I had to check this, as I didn't think NPM will do that, the content suggests it doesn't
unless Nodes are somehow packaged differently ?

No. I forgot the key part needed - to add a bundleDependencies section to the package.json:

I realise I tests the curl command using a node that had no dependencies.

1 Like

In general, I don't think nodes should be including a 'bundleDependencies' themselves... but if you're in a position of needing to pack them for offline install, you'll need to do the work to ensure the dependencies get included.

1 Like

Thank you for the solution,

But some nodes are installing and for some nodes sometimes i'm getting {"code":"unexpected_error","message":"Install failed"} , it is sporadic not everytime, for 4 to 5 times it is failing and if i try again node is installing, sometimes if i try continuosly 10 to 15 times also node is not installing(tries with /node-red-contrib-enigma-0.0.1.tgz node).

Can you please suggest me how i can resolve this issue? and how much size it will support to install offline(will it support all the nodes).

You'd have to check the node-red logs for any further information - although they may not have much there.

Otherwise, we'd have to try to debug it to see what exactly is happening.

1 Like

do we need to include only dependencies in bundleDependencies to pack the node or we need to add other things as well?

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.