DEV Community

Mario
Mario

Posted on • Originally published at mariokandut.com on

How to update Node.js?

There is a new major Node.js release version every 6 month (on average), so it keeps getting better and easier to use. 😎 A result of a continuous release cycle of Node.js is that existing applications are written aiming at a moving target, and applications have to be updated on a regular basis to ensure a working state in the future and no big version and feature jumps occur causing a big amount of adaption.

The Node.js community provides Long Term Support (LTS) releases to guarantee that the environment won't change for a fixed period. With LTS you get:

  • Critical bug fixes
  • Stable interfaces and APIs
  • Security updates
  • New features
  • Guarantee that the Node.js environment won't change for a fixed period (30 months), and gives time to update

Major Node.js versions enter Current release status for six months. After six months, odd-numbered releases (9, 11, etc.) become unsupported, and even-numbered releases (10, 12, etc.) move to Active LTS status and are ready for general use. Use only Active LTS or Maintenance LTS releases in production.

Node.js Releasesimage credit: Node.js Relases

Updating Node.js

For updating Node.js there are several options available depending on the way you first installed it.

Official Package

If you installed Node.js via downloading the official package, the package will already contain an installer which detects an existing version of Node.js. Hence, you just download the LTS version that fits your use case and run the installer.

NVM (preferred way)

The recommended way to install Node is via NVM (Node Version Manager), because you can manage multiple versions of Node.js. If you have used nvm to install Node.js, upgrading to a new version is one line. You can install a new Node.js version or basically any Node.js version using nvm install <VERSION>, like nvm install 10.16.3 or just install the latest LTS version with nvm install node. After installing the node version you want to use, you have to switch to it with nvm us <VERSION>, like nvm use 10.16.3 or nvm use --lts.

Homebrew (MacOs)

Homebrew is a very popular way to install software on Mac and upgrading Node.js is simple.

# update homebrew
brew update
# upgrade Node.js
brew upgrade node
Enter fullscreen mode Exit fullscreen mode

TL;DR

  • Use only Active LTS or Maintenance LTS releases in production.
  • Depending on how you installed Node.js you have to update it.
  • Preferred way of installing and updating is via nvm (node version manager).

Thanks for reading and if you have any questions , use the comment function or send me a message @mariokandut.

If you want to know more about Node, have a look at these Node Tutorials.

References (and Big thanks):

Node.js Relases, HeyNode, flavio

Top comments (0)