Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NodeJS module installation

I'm trying to install a NodeJS server on a computer without internet access. I copied the .exe and executed it but now I need to install a couple of modules, so my question is this:

Can I simply copy the modules from my PC? Or must I connect the server to the internet and use npm?

* EDIT : * I already had all the required modules into my PC, so I created the following package.json file:

{
  "name": "MyNodeJS",
  "version": "0.0.1",
  "author": "[email protected]",
  "description": "Modules required for MyNodeJS",
  "main": "index.js",
  "engines": {
    "node": ">= 0.6.6"
  },
  "dependencies": {
    "base64-js" : "0.0.2",
    "bignumber" : "1.1.0",
    "express" : "2.5.6",
    "socket.io" : "0.8.7"
  },
  "bundledDependencies":["base64-js","bignumber","express","socket.io"]
}

and then executed "npm pack" witch created MyNodeJS-0.0.1.tgz file with the following structure:

MyNodeJS-0.0.1.tgz
|- MyNodeJS-0.0.1.tar
   |- package
      |- ALL MY NODEJS CONTENT

Is this normal? Because I was expecting to have only the modules.

like image 966
Gonçalo Cardoso Avatar asked Nov 27 '25 10:11

Gonçalo Cardoso


1 Answers

You could create your own package.json. List all the modules you need under bundledDependencies and create a tarball via npm pack. Copy the tarball over to the new machine and install via npm install <filename>. That's it. npm is really sexy. ;-)

like image 90
Sebastian Stumpf Avatar answered Nov 29 '25 02:11

Sebastian Stumpf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!