NodeJS

Installing NodeJS v14 and Yarn package manager on Ubuntu

Install NodeJS 14 (LTS) on Ubuntu 20.04

Reference

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

Install Yarn Package Manager

As recommended by the setup script above:

curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn

Install NPM Packages Without Root Privileges

Reference

Create a local directory to install npm packages to:

mkdir ~/.npm-global

Configure npm to install packages to local directory:

npm config set prefix '~/.npm-global'

Add the bin directory to PATH, so executables installed by packages will be accessible. I set this in ~/.bashrc:

export PATH=~/.npm-global/bin:$PATH

Now npm install -g will install package to ~/.npm-global instead of /usr/local/.

Comments