How to update Node.js?
© https://nodejs.org/en/

How to update Node.js?

The proper way to upgrade Node.js

ByMario Kandut

honey pot logo

Europe’s developer-focused job platform

Let companies apply to you

Developer-focused, salary and tech stack upfront.

Just one profile, no job applications!

This article is based on Node v16.14.0.

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 Pragmatic Programmer: journey to mastery. 💰 One of the best books in software development, sold over 200,000 times.

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 Releases image credit: Node.js Releases

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

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 Releases, HeyNode, flavio

More node articles:

Getting started with Webpack

How to list/debug npm packages?

How to specify a Node.js version

How to create a web server in Node.js

How to dynamically load ESM in CJS

How to convert a CJS module to an ESM

How to create a CJS module

How to stream to an HTTP response

How to handle binary data in Node.js?

How to use streams to ETL data?

How to connect streams with pipeline?

How to handle stream errors?

How to connect streams with pipe?

What Is a Node.js Stream?

Handling Errors in Node (asynchronous)

Handling Errors in Node.js (synchronous)

Introduction to errors in Node.js

Callback to promise-based functions

ETL: Load Data to Destination with Node.js

ETL: Transform Data with Node.js

ETL: Extract Data with Node.js

Event Emitters in Node.js

How to set up SSL locally with Node.js?

How to use async/await in Node.js

What is an API proxy?

How to make an API request in Node.js?

How does the Event Loop work in Node.js

How to wait for multiple Promises?

How to organize Node.js code

Understanding Promises in Node.js

How does the Node.js module system work?

Set up and test a .env file in Node

How to Use Environment Variables in Node

How to clean up node modules?

Restart a Node.js app automatically

How to update a Node dependency - NPM?

What are NPM scripts?

How to uninstall npm packages?

How to install npm packages?

How to create a package.json file?

What Is the Node.js ETL Pipeline?

What is data brokering in Node.js?

How to read and write JSON Files with Node.js?

What is package-lock.json?

How to install Node.js locally with nvm?

How to update Node.js?

How to check unused npm packages?

What is the Node.js fs module?

What is Semantic versioning?

The Basics of Package.json explained

How to patch an NPM dependency

What is NPM audit?

Beginner`s guide to NPM

Getting started with Node.js

Scroll to top ↑