无人参与安装node.js和npm,但不从源代码构建它

时间:2022-05-03 06:31:26

Is there a way to install node.js and npm in an unattended way (with a shell script) without building it from source? I have an array of servers that scales automatically based on server load, but downloading the Node.js source and building it using make takes like 10 minutes.

有没有办法以无人值守的方式(使用shell脚本)安装node.js和npm而无需从源代码构建它?我有一组服务器可以根据服务器负载自动扩展,但下载Node.js源并使用make构建它需要10分钟。

Thanks!

edit: I tried copying over the binaries, but that resulted in an error that the binary was corrupted. And yes, they are all EC2 m1.small instances.

编辑:我尝试复制二进制文件,但这导致二进制文件已损坏的错误。是的,它们都是EC2 m1.small实例。

6 个解决方案

#1


2  

Assuming your script is something like:

假设你的脚本是这样的:

git clone https://github.com/joyent/node.git
cd node
./configure
make

Can you not just use the results from here on each new instance, and continue with:

您是否可以在每个新实例上使用此处的结果,并继续:

sudo make install
curl http://npmjs.org/install.sh | sudo sh

#2


4  

Since you're using EC2, it may help to make your own AMI. The most convenient way I have found is to:

由于您使用的是EC2,因此制作您自己的AMI可能会有所帮助。我发现最方便的方法是:

  1. Spin up a large, powerful machine
  2. 启动一台功能强大的大型机器

  3. Compile the latest stable Node.js
  4. 编译最新的稳定Node.js

  5. Install NPM, then Nave
  6. 安装NPM,然后安装Nave

  7. Install multiple versions of Node.js using Nave - each with their own NPM.
  8. 使用Nave安装多个版本的Node.js - 每个版本都有自己的NPM。

  9. Save this as an AMI
  10. 将此保存为AMI

I usually install 3-5 different versions depending on the project[1] and each has its own separate modules. Nave will sandbox the different Node versions and their modules.

我通常根据项目[1]安装3-5个不同的版本,每个版本都有自己独立的模块。 Nave将对不同的Node版本及其模块进行沙箱处理。

Then, once you have it set up the way you like it, you can easily spawn more servers from this master copy[2]. You could technically compile every Node.js version if you wanted to but I don't find this necessary.

然后,一旦你按照自己喜欢的方式进行设置,就可以轻松地从这个主副本中生成更多的服务器[2]。如果你愿意,你可以在技术上编译每个Node.js版本,但我不认为这是必要的。

[1] For example, the Braintree module currently requires Node.js@0.4.7 while the main codebase is on Node.js@0.4.1.
[2] As long as you stay consistent with architecture, if you compile all of this on a m1.xlarge, you can't use the image on m1.small's because xl is 64-bit and small is 32-bit.

[1]例如,Braintree模块当前需要Node.js@0.4.7,而主代码库在Node.js@0.4.1上。 [2]只要你与架构保持一致,如果你在m1.xlarge上编译所有这些,就不能在m1.small上使用图像,因为xl是64位而小是32位。

#3


4  

Maybe I'm late, but since now there are installable MSI files for Windows you can download the one corresponding to your platform (32 or 64bit) at:

也许我迟到了,但从现在开始有适用于Windows的可安装MSI文件,您可以下载与您的平台(32或64位)对应的文件:

http://nodejs.org/download/

and launch a silent install using msiexec /qn flag, check this post:

并使用msiexec / qn标志启动静默安装,请查看此帖子:

MSIEXEC Silent Mode Installation

MSIEXEC静默模式安装

node.js msi installers are pretty straigthforward now, they'll install node and npm on the PATH without extra steps.

node.js msi安装程序现在非常简单,他们将在PATH上安装node和npm而无需额外的步骤。

#4


1  

I'm assuming the servers are all the same platform/kernel, speaking from a redhat/centos enviornment... why not build it on one server then package the binaries into an RPM? You can then use that across your other servers. I'm assuming it's the same for deb packages if you are in a Debian enviornment.

我假设服务器都是相同的平台/内核,从redhat / centos环境说起......为什么不在一台服务器上构建它然后将二进制文件打包成RPM?然后,您可以在其他服务器上使用它。如果你在Debian环境中,我假设deb包也是一样的。

#5


1  

There is also a deb package if you are using Ubuntu (might work for other Debian or Ubuntu based distros as well):

如果您使用的是Ubuntu,也可以使用deb包(也可以用于其他基于Debian或Ubuntu的发行版):

http://blog.jetienne.com/2010/08/nodejs-deb-package-on-ubuntu-repository.html

sudo add-apt-repository ppa:jerome-etienne/neoip && 
     sudo apt-get update && 
     sudo apt-get install nodejs

..

$ node -v
v0.2.6

For npm:

curl http://npmjs.org/install.sh | sudo sh

#6


0  

I second James C's suggestion to build an RPM or whatever package system is appropriate for your OS distribution and then share it with your servers.

我的第二个James C的建议是构建一个适合您的操作系统分发的RPM或任何软件包系统,然后与您的服务器共享它。

#1


2  

Assuming your script is something like:

假设你的脚本是这样的:

git clone https://github.com/joyent/node.git
cd node
./configure
make

Can you not just use the results from here on each new instance, and continue with:

您是否可以在每个新实例上使用此处的结果,并继续:

sudo make install
curl http://npmjs.org/install.sh | sudo sh

#2


4  

Since you're using EC2, it may help to make your own AMI. The most convenient way I have found is to:

由于您使用的是EC2,因此制作您自己的AMI可能会有所帮助。我发现最方便的方法是:

  1. Spin up a large, powerful machine
  2. 启动一台功能强大的大型机器

  3. Compile the latest stable Node.js
  4. 编译最新的稳定Node.js

  5. Install NPM, then Nave
  6. 安装NPM,然后安装Nave

  7. Install multiple versions of Node.js using Nave - each with their own NPM.
  8. 使用Nave安装多个版本的Node.js - 每个版本都有自己的NPM。

  9. Save this as an AMI
  10. 将此保存为AMI

I usually install 3-5 different versions depending on the project[1] and each has its own separate modules. Nave will sandbox the different Node versions and their modules.

我通常根据项目[1]安装3-5个不同的版本,每个版本都有自己独立的模块。 Nave将对不同的Node版本及其模块进行沙箱处理。

Then, once you have it set up the way you like it, you can easily spawn more servers from this master copy[2]. You could technically compile every Node.js version if you wanted to but I don't find this necessary.

然后,一旦你按照自己喜欢的方式进行设置,就可以轻松地从这个主副本中生成更多的服务器[2]。如果你愿意,你可以在技术上编译每个Node.js版本,但我不认为这是必要的。

[1] For example, the Braintree module currently requires Node.js@0.4.7 while the main codebase is on Node.js@0.4.1.
[2] As long as you stay consistent with architecture, if you compile all of this on a m1.xlarge, you can't use the image on m1.small's because xl is 64-bit and small is 32-bit.

[1]例如,Braintree模块当前需要Node.js@0.4.7,而主代码库在Node.js@0.4.1上。 [2]只要你与架构保持一致,如果你在m1.xlarge上编译所有这些,就不能在m1.small上使用图像,因为xl是64位而小是32位。

#3


4  

Maybe I'm late, but since now there are installable MSI files for Windows you can download the one corresponding to your platform (32 or 64bit) at:

也许我迟到了,但从现在开始有适用于Windows的可安装MSI文件,您可以下载与您的平台(32或64位)对应的文件:

http://nodejs.org/download/

and launch a silent install using msiexec /qn flag, check this post:

并使用msiexec / qn标志启动静默安装,请查看此帖子:

MSIEXEC Silent Mode Installation

MSIEXEC静默模式安装

node.js msi installers are pretty straigthforward now, they'll install node and npm on the PATH without extra steps.

node.js msi安装程序现在非常简单,他们将在PATH上安装node和npm而无需额外的步骤。

#4


1  

I'm assuming the servers are all the same platform/kernel, speaking from a redhat/centos enviornment... why not build it on one server then package the binaries into an RPM? You can then use that across your other servers. I'm assuming it's the same for deb packages if you are in a Debian enviornment.

我假设服务器都是相同的平台/内核,从redhat / centos环境说起......为什么不在一台服务器上构建它然后将二进制文件打包成RPM?然后,您可以在其他服务器上使用它。如果你在Debian环境中,我假设deb包也是一样的。

#5


1  

There is also a deb package if you are using Ubuntu (might work for other Debian or Ubuntu based distros as well):

如果您使用的是Ubuntu,也可以使用deb包(也可以用于其他基于Debian或Ubuntu的发行版):

http://blog.jetienne.com/2010/08/nodejs-deb-package-on-ubuntu-repository.html

sudo add-apt-repository ppa:jerome-etienne/neoip && 
     sudo apt-get update && 
     sudo apt-get install nodejs

..

$ node -v
v0.2.6

For npm:

curl http://npmjs.org/install.sh | sudo sh

#6


0  

I second James C's suggestion to build an RPM or whatever package system is appropriate for your OS distribution and then share it with your servers.

我的第二个James C的建议是构建一个适合您的操作系统分发的RPM或任何软件包系统,然后与您的服务器共享它。