简体   繁体   English

NodeJS模块安装

[英]NodeJS module installation

I'm trying to install a NodeJS server on a computer without internet access. 我正在尝试在没有Internet访问权限的计算机上安装NodeJS服务器。 I copied the .exe and executed it but now I need to install a couple of modules, so my question is this: 我复制了.exe并执行了它,但现在我需要安装几个模块,所以我的问题是:

Can I simply copy the modules from my PC? 我可以简单地从我的电脑上复制模块吗? Or must I connect the server to the internet and use npm? 或者我必须将服务器连接到互联网并使用npm吗?

* EDIT : * I already had all the required modules into my PC, so I created the following package.json file: *编辑:*我已经将所有必需的模块放入我的电脑,所以我创建了以下package.json文件:

{
  "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: 然后执行“npm pack”,使用以下结构创建MyNodeJS-0.0.1.tgz文件:

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. 因为我期待只有模块。

You could create your own package.json. 你可以创建自己的package.json。 List all the modules you need under bundledDependencies and create a tarball via npm pack . 列出bundledDependencies下您需要的所有模块,并通过npm pack创建tarball。 Copy the tarball over to the new machine and install via npm install <filename> . 将tarball复制到新计算机并通过npm install <filename> That's it. 而已。 npm is really sexy. npm非常性感。 ;-) ;-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM