May 29, 2018 · Setup Guides Node.JS

Setup NodeJS on Ubuntu/Debian using NVM

DO NOT install NodeJS using the apt package!

Install NVM

NVM is a version manager for NodeJS. It will let you switch between NodeJS versions.

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

If using ZSH, add the following lines to your .zshrc

The installer automatically does this for bash.

echo 'export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion' >> ~/.zshrc

List available versions of NodeJS

nvm ls-remote

Screenshot-from-2018-05-26-12-04-08

Install and use the latest LTS version as default

nvm install 8.11.2
nvm use 8.11.2
nvm alias default 8.11.2

Update NPM

...just for good measure. No need to use sudo for global installs!

npm install -g npm