This article referred the following articles:
1. Install node.js
First, install the depended packages and get the node.js code from github.
sudo apt-get install g++ curl libssl-dev apache2-utils
besides the method above, you can also download the source code package from the “node.js” offical website.
Then make/install the node.js code.
2. Install npm (the node.js package manager)
Note that: if you compile “node.js” with the source code package downloaded from the offical website, then “npm” is ready to use and the following step is not required(at least for v0.8.0 it is, the version on Jun 26, 2012).
Install npm by running the following command:
curl http://npmjs.org/install.sh | sudo sh
Install some packages to test if npm works:
npm install socket.io # This will install the socket.io to your "~/.npm" directory.
Then you can review the install packages by running the following command:
node$ npm ls
3. Run some node.js code snippet to test if it works
var http = require('http');
Then run the following command to test the program:
The “uninstall” action requires you have the original source code when you did the installation. If you haven’t, you should download it first.
Then go to the root directory of the extracted source code, run:
sudo make uninstall
If you get some error message, such as some file is missing, you need to run “sudo make install” first, to reinstall/overwrite you installed same version “node.js”. Then run the “sudo make uninstall” again to uninstall. At this time it should success without error.
Then you can install the newer version of node.js as above.