Install NodeJS 10+ LTS on your laptop

Install NodeJS development environment, the right way.

Avatar of Author
Jean-Christophe BaeySeptember 10, 2019
NodeJS 10+ LTS
Photo by Garett Mizunaka on Unsplash

Installation of NodeJS and Node Packet Manager (NPM)

Linux

  • Install Node through NVM (Node Version Manager):
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
$ nvm install --lts
$ nvm alias default $(nvm current)

MacOS

  • Install Node through NVM (Node Version Manager):
$ brew install nvm
$ nvm install --lts
$ nvm alias default $(nvm current)

NVM commands to know:

  • List available remote LTS versions:
nvm ls-remote --lts
  • List locally installed versions:
nvm ls
  • Install a specific LTS version (using its code name)
nvm install Erbium
  • To switch to another version for the active shell use nvm use.
nvm use 12.16.3
  • To switch to the latest installed version:
nvm use node
  • To switch to the latest LTS version:
nvm use --lts
  • To switch the version of Node.js used by default when starting a new shell
nvm alias default {VERSION}
  • To get current used version
nvm current
  • Set the current used version as the default
nvm alias default $(nvm current)

Windows

  • Install using the install setup from node.org
  • A build chain should be installed for some native packages.

Build tool chain - Option 1 (recommended)

  • In an admin powershell:
npm install -g windows-build-tools

Build tool chain - Option 2

As an alternative, you can manually install VSCode 2015:

  • Install the build tool 2015 from Microsoft

  • Set VS 2015 as default version:

npm config set msvs_version 2015

Build tool chain - Common

  • Adding 2 directories in your windows path:

    • C:\Program Files (x86)\MSBuild\14.0\Bin\amd64
    • C:\Program Files (x86)\MSBuild\14.0\Bin
  • Install node-gyp from an administrator cmd:

npm install -g --msvs_version=2015 node-gyp rebuild
  • Check that you can see the msbuild version in command line:
msbuild /version

Yarn installation

Proxy for NPM

  • Don't forget to set the proxy if you are working in a corporate environment:
npm config set proxy http://<proxy url>:<proxy port>

👉 Don't forget to follow me on Twitter to be notified when new posts are available!

About

Personal website of Jean-Christophe Baey, technical articles on web and cloud technologies. My opinions are my own.

© 2022, Jean-Christophe Baey · All Rights Reserved · 0.1.0 · Privacy Statement