How to Update Node.js to Version [18, 20, 21 ,22] Ubuntu Terminal

Simple use nvm install <node-version> command to install the new version, and type nvm use <node-version> to switch to the new version on linux ubuntu command line or terminal.

How to Update Node.js to Version [18, 20, 21 ,22] Ubuntu Terminal?

Here are steps:

  • Step 1: Check the Current Node.js Version
  • Step 2: Install Node Version Manager (NVM)
  • Step 3: Install a New Node.js Version Ubuntu Linux
  • Step 4: Switch to the New Node.js Version
  • Step 5: Check the Node.js Version Again

Step 1: Check the Current Node.js Version

Press ctrl+alt+t on the keyboard to start the terminal window and check the current version of node js:

node -v

This will display the current version of Node.js installed on your system.

Step 2: Install NVM (Node Version Manager)

Run the curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash command in it, press enter and it will install nvm:

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

This command will download and install NVM on your Ubuntu system.

Step 3: Install a New Node.js Version (18,20,21,22)

To update whatever node js version is in the Ubuntu system using nvm install <node-version> command:

nvm install <node-version>

For version 18,

nvm install 18

For version 20,

nvm install 20

For version 22,

nvm install 22

Step 4: Switch to the New Node.js Version

Whatever version 18,20,21, or 22 of Node JS you want to update, you have installed it with the help of the above commands, and run nvm use <node-version> command to use updated version:

nvm use <node-version>

To update Node.js version to 18, you can use nvm use 18 command:

nvm use 18

Step 5: Check the Node.js Version Again

To verify that the new Node.js version is installed and active, Just type node -v command on terminal window or command line:

node -v

This should display the version of Node.js you installed using NVM.

Conclusion

In this tutorial, you have learned how to upgrade or update Node.js version on Ubuntu using NVM.

Recommended Tutorials

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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