Nodejs Introduction

BY Guanqiao Huang

Posted by HUANG on February 6, 2021

Reference

3 Ways to Update Node.js to Latest Version on Linux Systems

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

  1. Start by updating the package repository with the command: sudo apt update

  2. Install NVM using the curl command: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

Alternatively, you use wget and run the command: wget -q0- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

  1. Close and reopen the terminal for system to recognize the changes or run the command: source ~/.bashrc

  2. Then, verify if you have successfully installed NVM: nvm --version

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

  4. Now you can check for newly available releases with: nvm ls-remotes

  5. To install the latest version, use the nvm command with the specific Node.js version: nvm install [version.number]

Option 2: Update Node.js with NPM (Node Package Manager)

  1. First, clear the npm cache: npm cache clean -f

  2. Install n, Node’s version manager: npm install -g n

  3. With the n module installed, you can use it to:

Install the latest stable version: sudo n stable

Install the latest release: sudo n latest

Install a specific version: sudo n [version.number]