NodeJS module installation

2019-04-10 20:05发布

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": "aaa@aaa.aaa",
  "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.

1条回答
爷的心禁止访问
2楼-- · 2019-04-10 20:27

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. ;-)

查看更多
登录 后发表回答