开发者

Unattended install of node.js and npm, but without building it from source

开发者 https://www.devze.com 2023-03-13 17:57 出处:网络
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 ser

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.

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.


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

  1. Spin up a large, powerful machine
  2. Compile the latest stable Node.js
  3. Install NPM, then Nave
  4. Install multiple versions of Node.js using Nave - each with their own NPM.
  5. Save this as an 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.

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.

[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.


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:

http://nodejs.org/download/

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

MSIEXEC Silent Mode Installation

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


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


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.


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

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消