Alex Voytovich
Alex Voytovich

Reputation: 85

Is it possible to install global node packages offline?

I need to be able to install the carto module on an offline server. Is there a way that I could package up carto with all of its dependencies, and install it on a server that has no connection to the internet. The server won't have an initial connection, and will have npm and node installed from a .deb archive.

I've tried using npm-offline, as well as npm-offline-packer. These both require that I have an npm registry or a node project.

I'm hoping to have a start script that can run the required commands and get all packages installed. So far, I'm able to install all ubuntu software, just stuck on node.

Upvotes: 1

Views: 3034

Answers (1)

Cezar Augusto
Cezar Augusto

Reputation: 9892

An alternative would be installing it in another machine and copying the package(s) you want inside npm's global node_modules.

npm config get prefix

Gets the path to where it is installed. node_modules are usually under lib/ folder. Module executables could be located under bin/. Having both should be enough to use your global module in another machine.

Since you're looking for a start script the steps you need are:

  1. Getting npm prefix via npm config get prefix
  2. Go to that path
  3. Copy executables you want under bin/ i.e. carto@
  4. Copy content you want from lib/node_modules i.e. lib/node_modules/carto
  5. Apply to the machine you want using the same steps described here

Upvotes: 3

Related Questions