Install NodeJS and NPM on Ubuntu

Last updated:
Table of Contents

Updated for Ubuntu 20.04

Install Nodejs 16.x and NPM

Check if there are newer versions on this github link

Run these 2 commands: (you will get asked for your root password)

$ curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
$ sudo apt-get install -y nodejs

Check that you got the most recent versions

As of this post (2021), it's NPM 7.21.0 and NodeJS v16.8.0

$ npm -v
5.3.0
$ node -v
v16.8.0

Fix permissions

This is to enable you to install stuff without using sudo

type: sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

As per these instructions on the official npm docs

Dialogue & Discussion