0

How do I install node packages on an offline machine?

For instance, I am trying to install PhantomCSS onto a machine with no internet connectivity.

Anthony Ryan
  • 365
  • 2
  • 6
  • 19

1 Answers1

2

Using an automated package boxing tool like npmbox is preferred, because even though it can be done with npm alone, all dependencies must be carefully downloaded and installed. npmbox does the hard work for you. Perform npmbox phantomcss on a computer with an internet connection, take the resulting package to your offline computer via another means (such as a pen drive), then install the package with npmunbox phantomcss.npmbox.


Here is the alternative that I wrote before. I had chosen to follow this piece of advice for the answer.

Running npm view phantomcss will give you something like this at the end of the output:

dist:
{ shasum: '5a6cacc60934daed76031cf372a76aff240ba117',
 tarball: 'http://registry.npmjs.org/phantomcss/-/phantomcss-0.9.1.tgz' },
directories: {} }

Download the tarball on a computer with an internet connection. Transfer it to your offline computer, then install the package with npm install:

npm install /directory/to/your/package/phantomcss-0.9.1.tgz

Just appending what the other answer mentions: all other dependencies must be installed manually before doing this.

Community
  • 1
  • 1
E_net4
  • 27,810
  • 13
  • 101
  • 139
  • awesome thanks! any idea how to untar the npmbox.npmbox file? Is there something else I need to install in order to be able to run the tar command? – Anthony Ryan Jan 13 '15 at 01:46
  • Well yes! Install npmbox on both computers (npmunbox will be included). The package installation is already provided in the answer. – E_net4 Jan 13 '15 at 09:37
  • Thanks this was perfect! I'm trying to automate now and when running npmunbox from powershell or a batch it keeps trying to look online. Works fine if I type it in manually. Any ideas why this is? – Anthony Ryan Jan 14 '15 at 21:47
  • npmunbox phantomcss works fine when typed in manually. If I run a powershell or batch script with the same command it will run but tries to search online for the package (tries to hit bitbucket instead of just grabbing the .npmbox file) – Anthony Ryan Jan 14 '15 at 22:14