Is it possible to add node-red modules as .deb file dependencies so a user will not need an internet connection when installing?

I've created a Debian .deb package that populates my project onto a user's machine. I run "npm install" commands for my dependencies in the postinst script, but this requires the user to have an internet connection, which will not always be the case. I was wondering if there is a best practice where I can include the npm modues as dependencies that are included within the .deb file?

Thanks!

There was a thread about something similar in the past couple weeks. Did you read that?

Yes, it is possible. Node-RED is a node.js application and they are relatively straight-forwards to package into a redistributable archive.

The only tricky part would be if you had to handle more than one platform since some nodes require compiling. Not a problem if you are always on the same platform since the compiled code will work just fine.

1 Like

Thanks for the response, TI. When building my .deb package, there is a "control" file that contains a "Depends" and "Recommends" section, and if I add the names of debian software packages here they will be added to my .deb file. Is adding npm modules a similar process? Do you know of any good tutorials describing this process? I've searched endlessly and have come up short.

Thanks again!

I think that you are over complicating it.

There is no real link between a deb package and an npm package. You need to look at how Node.JS devs package up code for offline installation. Not an area that I am expert in.

The brute force method would be to install everything somewhere that has the same platform type and then take an archive of it, in your deb you should be able to unpack the archive on installation I think?

I'm sure there are probably better ways though.

Indeed that is the way we do it for the Pi build... do a clean install, remove a load of crud (like test and benchmark code), add the control files and, then pack it all back up as a deb. Ugly but it works.

1 Like

Perhaps look at https://www.npmjs.com/package/node-deb
We've used it successfully in the past. The idea is to npm install before building and including the node_modules folder in your build.

1 Like