Node.js provides installers for Windows and OSX operating systems and the source code package for Linux. In this post you’ll learn how to install node.js from source code on Linux. You can follow along this post for any Linux distribution like Ubuntu, Fedora and derivatives of these like Linux Mint.
Before installing node.js, you must have libssl-dev package installed in your system. It’s a security package which includes SSL development libraries and header files. If the package isn’t already installed, run the following command on Ubuntu Terminal.
sudo apt-get install libssl-dev
It is possible that when you’re reading this post, Node.js has been updated to a new version. So, just visit the Node.js Downloads page and right click and copy the Source Code link.
Now enter the
/tmp directory and download the package into it running the following command.
cd /tmp wget http://nodejs.org/dist/v0.12.2/node-v0.12.2.tar.gz
Once you’ve the node.js package downloaded, unzip it in the same directory. Use the following command to verbosely extract downloaded package.
tar -vxf node-v0.12.2.tar.gz
node-v0.12.2.tar.gz with your package name.
To install node.js, enter the newly created directory through the previous command.
./configure command check the prerequisites and other necessary files for installation. If you get a successful message, go to build step, or install the required packages.
Next step is to build the source code. This step will take few minutes to complete. Run
make command to build the source code.
The last step is installation. Install using following command with sudo access.
sudo make install
So now, we’ve Node.js installed on our system. To check this, run the following command which will tell the Node.js version installed on your system:
Great! In few easy steps, you’ve shiny new node.js installed on your Linux system build from latest version of source code.