UPDATE: Since writing this I have decided to take better control over the process, and install Node.js on Ubuntu using the package manager
I’m still very new to Ubuntu, but even so have found installing Node.js to be pretty easy.
You could follow the instructions on Nodejs.org to get it up and running. Or you could do what I did and use this excellent ShellScript by Ruslan Khissamov.
I chose to go this route as:
- I’m impatient and want to get going in Node as soon as possible
- It also installs the Node Package Manager (NPM)
- You can configure it to install the database of your choice at the same time
Using the ShellScript to install Node.js and MongoDB
1: Create the configuration
Using the radio buttons and checkboxes select which Ubuntu Package Manager (UPM) and database you want to use, and whether you want to install the Cloud9 IDE. As you make changes you’ll notice the text to the right of the buttons changing reflecting your choices.
I have chosen the default UPM apt-get, MongoDB and also to install Cloud9.
2: Create the ShellScript file
You can use a text editor to create the file, or use the code provided to do it for you. Open a terminal window and paste the following:
cd ~/ nano -w node.sh
This makes sure you’re in your home directory and creates a file called node.sh, opening it in Nano. Nano is a text editor that runs in the terminal.
Paste the script that you configured into the text editor. It should look something like this:
Press Ctrl+X followed by Y to exit Nano and save the changes.
3: Run the ShellScript file
Paste this into terminal to run as administrator – you will be asked for your password.
chmod +x node.sh && sudo ./node.sh
When you enter your password the script will run, downloading and installing Node.js and anything else you selected.
For me this took about 5 minutes, but it will depend on the options you selected, and your internet connection speed. When everything is finished you’ll be presented with your normal terminal prompt. Mine looked like this:
All done, Node.js is installed!
A quick reboot, and there you have it! Node.js, NPM, MongoDB and Cloud9 IDE all installed in a few minutes. I told you it was pretty easy!