# \[Question\] Best way to install modules to an offline pc

**URL:** <https://discourse.nodered.org/t/question-best-way-to-install-modules-to-an-offline-pc/20902>\
**Category:** General\
**Created:** [27 January 2020 09:04 UTC](https://discourse.nodered.org/t/question-best-way-to-install-modules-to-an-offline-pc/20902 "2020-01-27T09:04:43Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nxito](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nxito/32/88293_2.png) [@Nxito](https://discourse.nodered.org/u/Nxito)\
**Post date:** [27 January 2020 09:04 UTC](https://discourse.nodered.org/t/question-best-way-to-install-modules-to-an-offline-pc/20902/1 "2020-01-27T09:04:43Z")

</div>

Hi,  
to start, i'm using windows 10 :

The problem is: what is the best way to install a module such as node-red-contrib-s7 (for example) on a computer without internet connection?

On this offline device I have copied my Node-Red project but I am missing this node  
(I have copied node-Red directly from a computer with connection to this offline one)

I think that copying a node directly is not the best way because there may be problems with versions or dependencies

How would you do it?

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [27 January 2020 09:17 UTC](https://discourse.nodered.org/t/question-best-way-to-install-modules-to-an-offline-pc/20902/2 "2020-01-27T09:17:49Z")

</div>

That topic came up here before.

See this thread for some ideas:

> [@Installing Node-RED on a Work (Corporate) Laptop](https://discourse.nodered.org/t/installing-node-red-on-a-work-corporate-laptop/17683/8):
>
> No, but you can install it on another machine (same OS, NodeJS and architecture) and copy the whole installation to your target machine with an USB stick (thumb drive). That's how I do it, works fine for Windows and Linux. It's important to do a local install (no -g flag). Just run npm install node-red in an empty directory.

---

<div class="post-metadata">

**Author:** ![Nxito](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nxito/32/88293_2.png) [@Nxito](https://discourse.nodered.org/u/Nxito)\
**Post date:** [27 January 2020 09:43 UTC](https://discourse.nodered.org/t/question-best-way-to-install-modules-to-an-offline-pc/20902/3 "2020-01-27T09:43:31Z")

</div>

The problem is similar, yes, but not the same.

I already have NodeRed installed on my offline PC and I want to install a dependency like when you run (for example): npm install node-red-contrib-s7

I have tried to copy the npm cache of the online machine, copy it to the other and try to install it. Sometimes it works  
I have tried to use "npm pack" with this method, but it does not seem the most appropriate, because in addition to not always working, it takes too much to copy the cache from one machine to another

Another option would be to reinstall everything, but I already have a service created

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [27 January 2020 09:50 UTC](https://discourse.nodered.org/t/question-best-way-to-install-modules-to-an-offline-pc/20902/4 "2020-01-27T09:50:35Z")

</div>

I think the solution is the same.  
Just run `npm install node-red-contrib-s7` in the NR workspace of your _online_ machine, and copy the whole workspace to your _offline_ machine (important is the `node_modules` dir).  
By workspace I mean the directory where your `flows.json` resides. I don't recommend installing nodes globally.

In principle, this is how I do it all the time, as our customers' production machines have no internet connection.

No npm cache needed.  
"npm pack" is for building an archive when developing packages.

---

<div class="post-metadata">

**Author:** ![Nxito](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nxito/32/88293_2.png) [@Nxito](https://discourse.nodered.org/u/Nxito)\
**Post date:** [27 January 2020 10:29 UTC](https://discourse.nodered.org/t/question-best-way-to-install-modules-to-an-offline-pc/20902/5 "2020-01-27T10:29:43Z")

</div>

In this case, would you overwrite the node\_modules folder or skip those dependencies already installed? Couldn't there be a problem with the versions of each one?

on the other hand, this method seems simpler and more effective than what I was trying

I think it's basically copy node\_modules and add the dependency manually to packages.json

or am I wrong?

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [27 January 2020 10:48 UTC](https://discourse.nodered.org/t/question-best-way-to-install-modules-to-an-offline-pc/20902/6 "2020-01-27T10:48:50Z")

</div>

In most cases I just replace the `node_modules` with the new one (rename or move it away first), so I always get a state that's consistent with the online machine. Plus, I have the option to quickly roll-back the old state by restoring the renamed `node_modules` directory if something goes wrong.

You don't _need_ to update the package.json of your workspace, it isn't required by Node-RED or NodeJS to run. But I _recommend_ keeping both workspaces (online and offline) in sync.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 January 2020 11:13 UTC](https://discourse.nodered.org/t/question-best-way-to-install-modules-to-an-offline-pc/20902/7 "2020-01-27T11:13:16Z")

</div>

> [@kuema](#):
>
> You don't _need_ to update the package.json of your workspace,

If you don't then npm will (almost) silently remove the package if you run npm, so suddenly you find that half your packages are missing.

@Nxito, in case you had not realised, I believe that @kuema maintains a full copy of the working system on his online system so that the whole thing can be copied across. The problem with trying to copy over just the new modules is that one module may bring other modules so you have to copy those also.

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [27 January 2020 11:18 UTC](https://discourse.nodered.org/t/question-best-way-to-install-modules-to-an-offline-pc/20902/8 "2020-01-27T11:18:00Z")

</div>

> [@Colin](#):
>
> If you don't then npm will (almost) silently remove the package if you run npm, so suddenly you find that half your packages are missing.

I meant the offline copy of the workspace... you don't run npm there anyway. As I said, I recommend keeping them in sync anyway. 🙂

> [@Colin](#):
>
> @kuema maintains a full copy of the working system on his online system so that the whole thing can be copied across

Indeed, that's the case. That online workspace is complete with package.json, flows.... etc. and checked into Git.

We've been using this workflow at work for some time now. We haven't come up with a better solution yet. But as I can see, we're not the only ones with that requirement. 😅

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 January 2020 11:25 UTC](https://discourse.nodered.org/t/question-best-way-to-install-modules-to-an-offline-pc/20902/9 "2020-01-27T11:25:52Z")

</div>

> [@kuema](#):
>
> I meant the offline copy of the workspace... you don't run npm there anyway.

It would be easy, I think, to forget which system you were on and try to use npm to install something. I don't know whether running something like `npm list` would remove them. I would not be surprised.

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [27 January 2020 11:32 UTC](https://discourse.nodered.org/t/question-best-way-to-install-modules-to-an-offline-pc/20902/10 "2020-01-27T11:32:09Z")

</div>

Well, if you keep the project files in sync the problem won't occur.

And in my case, I don't even have NPM on the offline machines available in the first place, so I never ran into that trap. 🙂

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [27 January 2020 16:00 UTC](https://discourse.nodered.org/t/question-best-way-to-install-modules-to-an-offline-pc/20902/11 "2020-01-27T16:00:52Z")

</div>

I agree, use an online device - of the same platform type - to build a working environment and then synchronise it to the offline device - with a USB stick and RSYNC on both ends maybe if truly offline.

Removing npm from the offline device is a good idea. You should also remove npx as well.

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [27 January 2020 16:22 UTC](https://discourse.nodered.org/t/question-best-way-to-install-modules-to-an-offline-pc/20902/12 "2020-01-27T16:22:21Z")

</div>

> [@TotallyInformation](#):
>
> Removing npm from the offline device is a good idea. You should also remove npx as well.

In fact, I only keep the `node.exe` on our Windows-based production systems. Also easier to upgrade, because you can download the archive (no installer) from [NodeJS](https://nodejs.org/dist/latest-v10.x/) and exchange the executable.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [27 March 2020 16:22 UTC](https://discourse.nodered.org/t/question-best-way-to-install-modules-to-an-offline-pc/20902/13 "2020-03-27T16:22:24Z")

</div>

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