Node.js is an open-source JavaScript runtime environment. Since Node.js has an active community of users, minor updates of the software come out every few weeks.

We have to make sure to update Node.js regularly to ensure system security, and there are several ways we can do it, depending on the operating system running on our machine. (Linux / Windows / macOs )

Update Node.js to Latest Version on Windows

Updating Node.js on Windows and macOS follows the same principles.

There are two simple ways to upgrade:

  1. Download the latest Node.js release from its official download page and install the new Node.js release.
  2. Install the n module and update Node.js inside the terminal window.

Option 1: Update Node.js with Installer

One way to update your Node.js is to go to its official download page (https://nodejs.org/en/) and install the newest release. By doing so, the system should overwrite the older version with the updated one.

Option 2: Update Node.js with NPM

If you want to upgrade Node.js from the command line, use the n model within the npm command. The n feature allows you to interact with different Node.js versions.

1. Before updating the Node.js release, check which version you are currently using with:

node -v

2. Next, clear npm cache with the command:

npm cache clean -f

3. Install n globally:

npm install -g n

4. Now that you have n installed, you can use the module to install the latest stable release of Node.js:

sudo n stable

Alternatively, you can install the Node.js release with the latest features:

sudo n latest

Or, install a specific version number with:

n [version.number]

Option 3 : Update Node.js with nvm
nvm install NEW_VERSION --reinstall-packages-from=OLD_VERSION
// For example:
nvm install 6.7 --reinstall-packages-from=6.4

then, if you want, you can delete your previous version with:

nvm uninstall OLD_VERSION
// For example:
nvm uninstall 6.4

Alternatively, try:

Latest version:

nvm install node --reinstall-packages-from=node

Stable (LTS) version: (if currently in use)

nvm install "lts/*" --reinstall-packages-from="$(nvm current)"

This will install the appropriate version and reinstall all packages from the currently used node version.

This saves you from manually handling the specific versions.

RESUME :
nvm install <version>

//Check the list of available Node.js version in the system using the following command:
nvm list 

// To use the desired version, use the following command:
nvm use <version>








By Shabazz

Software Engineer, MCSD, Web developer & Angular specialist

Leave a Reply

Your email address will not be published. Required fields are marked *