Save external libraries in the current version for future development

Hi everyone, i need to save some modules locally to be sure to use them in a certain version.
Is there any way to do this?
I'm trying to use "npm install " first taking the modules present in ".node-red / node_modules" but I think it's not the right way to do it, could you tell me how to do it?

Can you give a real example of exactly what you want to achieve so that we can fully understand what you mean by that statement.

npm install will use the package.lock.json file by default which has explicit module versions in it. The way to do a fully encapsulated deployment is to use the shrinkwrap feature of npm. Can't help with the details for that I'm afraid since I haven't done it for a few years.

1 Like

I need to take external modules, for example "node-red-contrib-modbus" and install it locally, so even without an internet connection

If you search the forum for
install nodes without internet connection
it will find threads discussing how to do this. This one for example [Question] Best way to install modules to an offline pc

Maybe I didn't understand it well but it seems slightly different as a question, what should I do if I need to individually save each module with its dependencies and not all installed modules together ?

I tried "npm install <path/to/folder>".
I got the modules from another machine with it installed

Why do you want to do that?

To ensure future compatibility on older installations. (I have edited the last reply with an example

In that case, if the new system does not have internet access, copy the whole node_modules, package.json and package-lock.json from the master system to the new one.
If the new system does have internet access then just copy the two package files across, go into the .node-red folder and run
npm install
That will install exactly the same versions as on the original system. The package lock file tells it exactly which module versions to install.
You would also have to make sure the systems have the same node-red and nodejs versions installed.

1 Like

Ok thanks, so I should install the whole project.
There is a way to also save a version of node red and node.js as if they are .exe to install

You will need to use something like npm-bundle

1 Like

You should probably choose a local install of Node-RED instead of a global one if you want that. There is an example installer in my GitHub.

I saw your library, I have to install my application on windows OS and has to start at every start. Shouldn't this give me some trouble?

No, it works fine on Windows, I use it more there than on Linux in fact since Windows is my dev environment.

Though it has a starter script for auto-starting under Linux systemd, you have to set that up yourself anyway. I don't auto-start on Windows and use PM2 to manage things there since I can add watch folders that will auto-restart if files change.

1 Like

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