banner



How To Update Node Js Through Npm

Introduction

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

You lot may be using Node.js equally a layer of the MEAN stack or in a different JS framework. Either way, make certain to update Node.js regularly to ensure system security.

There are several means to install Node.js and NPM. Also, there are several means to update your Node.js version, depending on the operating organisation running on your car.

In this article, y'all volition learn how to update to the latest Node.js version on Linux, Windows, and macOS.

tutorial on how to update Node.js to latest version

iii Means to Update Node.js to Latest Version on Linux Systems

There are different ways to update Node.js if you are using a Linux-based system. Although using the Node Version Manager is the easiest and virtually recommended selection, you can too update with the local bundle manager or by downloading the binary packages.

Option 1: Update Node.js with NVM (Node Version Manager)

The best mode to upgrade Node.js is with NVM, a practical tool for managing multiple Node.js versions.

1. Outset past updating the package repository with the command:

          sudo apt update        

2. Install NVM using the curl control:

          curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | fustigate        

Note: If you don't accept curlicue , install the utility by running the command: sudo apt install curl .

Alternatively, yous use wget and run the command:

          wget -q0- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | fustigate        

3. Close and reopen the terminal for organisation to recognize the changes or run the command:

          source ~/.bashrc        

5. Then, verify if you have successfully installed NVM:

          nvm --version        

six. Before upgrading Node.js, check which version you have running on the system:

          nvm ls        

seven. Now you tin check for newly bachelor releases with:

          nvm ls-remote        
see a list of all available Node.js versions

8. To install the latest version, use the nvm command with the specific Node.js version:

          nvm install [version.number]        

Selection two: Update Node.js with NPM (Node Package Managing director)

As an alternative, you tin use Node'southward official package manager to update Node.js. NPM is a tool for installing and managing parcel dependencies.

If you have Node on your arrangement, you have NPM, also. With the npm command, you tin can check running Node.js versions and install the latest release.

Past calculation the n module, you can interactively manage Node.js versions.

ane. Beginning, articulate the npm cache:

          npm cache make clean -f        
clear npm cache

2. Install n, Node's version manager:

          npm install -m n        

three. With the north module installed, you can use it to:

Install the latest stable version:

          sudo n stable        

Annotation: Some Ubuntu distros may answer with the command not establish output after running the north command. To fix this upshot run sudo -E env "PATH=$PATH" [command] . For case, to install the latest stable version, as in the example higher up, you lot would run sudo -Due east env "PATH=$PATH" due north stable .

Install the latest release:

          sudo n latest        

Install a specific version:

          sudo due north [version.number]        

Option 3: Update Node.js with Binary Packages

Updating Node.js with binary packages is the to the lowest degree recommended option. However, if information technology is the only manner you tin can upgrade to the latest Node.js version, follow the steps outlined below.

ane. Navigate to Node's official downloads folio where you can find all available packages. There you can download the source code or pre-built installer for the LTS versions or the latest release.

ii. Y'all can either download the package from your browser or find the version number you need and add it to the wget command:

          wget https://nodejs.org/dist/v14.17.0/node-v14.17.0-linux-x64.tar.xz        

iii. Side by side, install xz-utils used to extract the binary package:

          sudo apt-get install xz-utils        

4. Extract and install the package with the control:

          sudo tar -C /usr/local --strip-components 1 -xJf node-v14.17.0-linux-x64.tar.xz        

Update Node.js to Latest Version on Windows and macOS

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

There are two unproblematic means to upgrade:

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

Choice 1: Update Node.js on Windows and macOS with Installer

One way to update your Node.js is to become to its official download folio and install the newest release. Bz doing so, the system should overwrite the older version with the updated one.

1. Navigate to the Node.js website and click on the latest stable version or the newest electric current release (with the latest features).

2. Subsequently deciding the version, click on theWindows or themacOS Installer, depending on the organisation you are using. The system downloads the parcel and stores information technology in the specified directory.

iii. Once the download is complete, run the installer.

4. The Node.js Setup Wizard appears and guides yous through the installation.

Node.js installation wizard

5. Accept the License Agreement past checking the box and click Next.

Node.js licensing agreement

six. Cull the destination folder where you want to install Node.js.

install latest Node.js on Windows

7. Node.js allows you to select how you want to install the Node features. Change the way the features are installed by clicking on the icons in the tree.

Custom Setup for Node.js

8. With that, the latest Node.js is ready to install. Click Install to confirm, wait until the installation completes, and click Finish.

nine. Cheque the Node.js version with the command:

          node -v        

Note: Sometimes, the system fails to overwrite the older Node.js release and you may end upwardly with two versions. If such problems occur, yous may want to consider updating with NPM, outlined in the section below.

Option 2: Update Node.js on Windows and macOS with NPM

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

one. Earlier updating the Node.js release, cheque which version you are currently using with:

          node -v        

2. Adjacent, clear npm cache with the command:

          npm cache clean -f        

iii. Install n globally:

          npm install -g n        

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

          sudo north stable        

Alternatively, y'all can install the Node.js release with the latest features:

          sudo n latest        

Or, install a specific version number with:

          north [version.number]        

Conclusion

The best part of open-source engineering is its strong community of users constantly working on upgrading the software.

Node.js is a good example of such software as new versions come out regularly. Users tin can choose whether they desire to work with the LTS (the long-term supported version) or the latest version with the newest features.

This commodity should accept helped yous update Node.js on whatever operating organization.

Was this article helpful?

Yes No

How To Update Node Js Through Npm,

Source: https://phoenixnap.com/kb/update-node-js-version

Posted by: alfonsodarphe.blogspot.com

0 Response to "How To Update Node Js Through Npm"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel