4

I've got a script that automatically installs some npm packages (specifically karma, which I'd like to install with --global) on an EC2 instance on startup. The problem is that npm sometimes randomly fails, presumably due to network hiccups, though I'm not entirely sure what's going on.

To rule out the network, what I'd like to do is download the relevant files for npm and ask it to install karma based on the files as I download them from S3.

But how do I do that? How do I tell npm not to grab files from the central repository and to instead grab them from somewhere else?

Dan Fabulich
  • 477
  • 1
  • 6
  • 17

3 Answers3

2

You have to first install npmbox module globally, This module creates an Offline package with all depedencies of given module. Then you could use npmunbox command to install that package to your offline machine.

To install npmbox: npm install -g npmbox

To create offline package of a module: npmbox -v localtunnel, It will generate a localtunnel.npmbox file to current directory. Copy that you your offline machine.

To install offline package: npmunbox localtunnel.npmbox

For more info: https://github.com/arei/npmbox

vs4vijay
  • 121
  • 5
0

I have written a Simple and transparent tool to do npm install using npm's offline cache

Please see https://github.com/harish2704/npm-offline-registry

harish2704
  • 101
  • 1
0

INSTALL PM2 OFFLINE:-

Tested on Node-v6.10.3 and Npm-3.10.10 on RHEL-7

Go to machine with internet connection:-

#npm install -g npmbox
#npmbox npmbox
#scp npmbox.npmbox root@offline-server-ip:.

Go to machine without internet connection :-

#ssh  root@offline-server-ip 
#tar --no-same-owner --no-same-permissions -xvzf npmbox.npmbox
#npm install --global --cache ./.npmbox.cache --optional --cache-min 99999999999 --shrinkwrap false npmbox

Go to machine with internet connection:-

#npm install pm2 -g
#npmbox pm2
#scp pm2.npmbox root@offline-server-ip:.

Go to machine without internet connection :-

#npmunbox pm2.npmbox --global
#pm2 ls