Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
vms:webdev:node [2017/06/17 18:15]
admin [Install NVM (Node Version Manager)]
vms:webdev:node [2017/09/07 18:16] (current)
admin [Run the Install Script]
Line 3: Line 3:
 As always, we'll start from a [[:​vms:​debian|Debian template]].\\ As always, we'll start from a [[:​vms:​debian|Debian template]].\\
 We'll refer to [[http://​yoember.com/​nodejs/​the-best-way-to-install-node-js/​|this article]], stating it's the best way to install Node.js ! We'll refer to [[http://​yoember.com/​nodejs/​the-best-way-to-install-node-js/​|this article]], stating it's the best way to install Node.js !
 +
 +===== Create User =====
 +
 +We'll first create a ''​dev''​ user that is going to be part of the ''​sudoers''​ group ([[https://​www.digitalocean.com/​community/​tutorials/​how-to-create-a-sudo-user-on-ubuntu-quickstart|DigitalOcean reference]]).
 +
 +<​Code>​
 +> adduser dev
 +...
 +Enter new UNIX password: ​
 +Retype new UNIX password: ​
 +...
 +> usermod -aG sudo dev
 +</​Code>​
 +
  
 ===== Install NVM (Node Version Manager) ===== ===== Install NVM (Node Version Manager) =====
 +
 +**NOTE:** the following commands will be executed as ''​dev''​ user.
 +==== Run the Install Script ====
  
 Check [[https://​github.com/​creationix/​nvm#​install-script|the NVM GitHub repo]] for the latest version of the script. Check [[https://​github.com/​creationix/​nvm#​install-script|the NVM GitHub repo]] for the latest version of the script.
  
 <​Code>​ <​Code>​
-> wget -qO- https://​raw.githubusercontent.com/​creationix/​nvm/​v0.33.2/install.sh | bash+> wget -qO- https://​raw.githubusercontent.com/​creationix/​nvm/​v0.33.4/install.sh | bash
 => Downloading nvm as script to '/​root/​.nvm'​ => Downloading nvm as script to '/​root/​.nvm'​
  
Line 22: Line 39:
  
 In case you'd like to better grasp what the script exactly does, and what files it involves, you can refer to [[https://​github.com/​creationix/​nvm#​manual-install|https://​github.com/​creationix/​nvm#​manual-install]] In case you'd like to better grasp what the script exactly does, and what files it involves, you can refer to [[https://​github.com/​creationix/​nvm#​manual-install|https://​github.com/​creationix/​nvm#​manual-install]]
 +
 +==== Choose the Node.js Version to Install ====
 +
 +First you can **list the installed Node.js** versions:
 +<​Code>​
 +> nvm list
 +nvm list
 +            N/A
 +node -> stable (-> N/A) (default)
 +iojs -> N/A (default)
 +</​Code>​
 +
 +Next you can **list the available Node.js versions**:
 +<​Code>​
 +> nvm ls-remote
 +        v0.1.14
 +        v0.1.15
 +        v0.1.16
 +        v0.1.17
 +        ...
 +        ...
 +         ​v7.9.0
 +        v7.10.0
 +         ​v8.0.0
 +         ​v8.1.0
 +         ​v8.1.1
 +         ​v8.1.2
 +</​Code>​
 +
 +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 ====
 +
 +<Code
 +> nvm install 7.10.0
 +</​Code>​
 +
 +When you have many Node.js versions, change the default with:
 +<​Code>​
 +> nvm use 8.0.0
 +> nvm alias default 8.0.0
 +</​Code>​
 +
 +To check the current default version:
 +<​Code>​
 +> node -v
 +</​Code>​
 +
 +==== Upgrade NPM to the Last Version ====
 +
 +<​Code>​
 +> npm -v
 +4.2.0
 +
 +> npm install -g npm
 +> npm -v
 +5.0.3
 +</​Code>​
 +
 +==== Increases the Amount of inotify Watches ====
 +
 +<​Code>​
 +> echo fs.inotify.max_user_watches=524288 | sudo tee -a /​etc/​sysctl.conf && sudo sysctl -p
 +</​Code>​