In this post, we log the steps to install Node.js on Ubuntu from source (the alternatives are many to install from package manger with one good source of information here )
Step 1 – Get the source from Nodejs.com
Go to to http://nodejs.org and copy link of the source tar file of your interest. Afterwards, open console and move, unpack, extract the file as follows:
wget https://nodejs.org/download/release/v0.10.6/node-v0.10.6.tar.gz tar xvzf node-v0.10.6.tar.gz cd node-v0.10.6
Make sure your grab the right one source package not the binary archive packages, otherwise you will miss necessary files such as .configure to install it in next step
Step 2 – Compile and Install Node JS
From the console, run the following commands:
cd node-v0.10.6 ./configure make make install
Firs, the configuration is created created in line 1. Then, the ‘make’ command compiles Node.js after. Afterwards, the ‘make install’ does the installation including copying files accordingly
Step 3 – Test the Installation
Check the version:
Lets create file test.js that contains the following line:
Afterwards, run this node.js script:
This should display the ‘hello world’ text
NOTE: Make sure you check Node Version Manager tool that will automatically grab Node.js and let you install version you wish.
First, lest find out which executable used for nodejs
This will return something like /path/bin/node.
Next, go to the path dir:
Once in the /path dir, to remove:
rm -r bin/node bin/node-waf include/node lib/node lib/pkgconfig/nodejs.pc share/man/man1/node.1
This will remove Nodejs but not npm. If you install npm again into a custom path that starts off empty, then you can see what it adds and then you will be able to make a list for npm similar to the above list I made for node.