Node.js Installation

As always, we'll start from a Debian template.
We'll refer to this article, stating it's the best way to install Node.js !

We'll first create a dev user that is going to be part of the sudoers group (DigitalOcean reference).

> adduser dev
Enter new UNIX password: 
Retype new UNIX password: 
> usermod -aG sudo dev

NOTE: the following commands will be executed as dev user.

Run the Install Script

Check the NVM GitHub repo for the latest version of the script.

> wget -qO- | bash
=> Downloading nvm as script to '/root/.nvm'

=> Appending nvm source string to /root/.bashrc
=> Appending bash_completion source string to /root/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:

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

In case you'd like to better grasp what the script exactly does, and what files it involves, you can refer to

Choose the Node.js Version to Install

First you can list the installed Node.js versions:

> nvm list
nvm list
node -> stable (-> N/A) (default)
iojs -> N/A (default)

Next you can list the available Node.js versions:

> nvm ls-remote

The list being very long, it is possible to reduce the output using something like: $ nvm ls-remote | tail -n9 to only display the last 9 versions or $ nvm ls-remote | grep “v7” to only view version 7…

Install NVM Version and Set Default


nvm install 7.10.0


When you have many Node.js versions, change the default with:

> nvm use 8.0.0
> nvm alias default 8.0.0

To check the current default version:

> node -v

Upgrade NPM to the Last Version

> npm -v

> npm install -g npm
> npm -v

Increases the Amount of inotify Watches

> echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p