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- | 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_DIR/"  # 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


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