I spent a while trying to figure out how to elegantly install node.js and npm in EC2 with Amazon Linux using an rpm package manager like yum. Node.js takes 30 minutes to compile on a micro instance so if you plan to use cloud-formation or spin up new instances to handle load, you need to install with a package manager.
The first thing you have to do is create a machine. I created a 64 bit micro instance of Amazon. You can also do this through the console but I prefer the CLI.
Then I find out the CNAME of the machine.
Then login to the machine.
There is a project on git called node-npm that has a good wiki on how to build the node.js package. Now that you are into the machine, install the stuff we need for nodejs-rpm and the build process.
Then get the nodejs-rpm project and move to that directory.
cd nodejs-rpm
And then build the thing.
spectool -g -R nodejs.spec
rpmbuild -ba nodejs.spec
It will produce your RPM files.
/home/ec2-user/rpmbuild/RPMS/x86_64/nodejs-0.8.16-2.amzn1.x86_64.rpm
/home/ec2-user/rpmbuild/RPMS/x86_64/nodejs-binary-0.8.16-2.amzn1.x86_64.rpm
I then copied nodejs-0.8.16-2.amzn1.x86_64.rpm over to an S3 bucket so that I could install them directly the next time I built a machine.
Now I can just create a new machine and install node via yum.