/ devps

Installing NodeJS on Ubuntu

Installing NodeJS on Ubuntu is a piece of cake. Let’s check out various ways of how this can be done.

1. Installing NodeJS using package manager

NodeJS is available in NodeSource or via Ubuntu software package repositories. I prefer to use it via Debian Nodesource as you can selectively pick the desired version you want.

Here’s how you can add Nodesource of version 6 and install it in your Ubuntu

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - sudo apt-get install -y nodejs

You can also do the same for the Node version 8 or more.

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install -y nodejs

To add optional build tools required by NPM for some native packages.

sudo apt-get install -y build-essential

2. Installing NodeJS using NVM

Node version manager is a great tool you can use to download, install and use multiple versions of Node concurrently. Let’s get the NVM install on your Ubuntu.

env VERSION=`python tools/getnodeversion.py` make install DESTDIR=`nvm_version_path v$VERSION` PREFIX=""

Once you have NV, you can easily switch to different versions of Node, install or uninstall it.

nvm install 8 nvm use 6 nvm uninstall 8

You can check out more about the setup process here.

Love Hasija

Love Hasija

Full Stack Research Engineer, Software Architect | Helped build next generation software systems | Distributed Systems Fanatic | Open Source Hacker.

Read More