Find out how to Set up and Handle A number of Variations of Node.js on Linux

If you've ever had problems running a project because you didn't install a compatible version of Node.js, you are not alone. Fortunately, there is a simple solution to this problem.

Node Version Manager (NVM) allows you to install multiple versions of Node.js on your computer and choose which version to use depending on the project you want to run.

NVM is an open source project that aims to simplify the installation and administration process of Node.js.

What is Node.js?

Node.js is an open source, cross-platform JavaScript runtime environment based on Google Chrome's V8 engine. Node.js allows you to run and run JavaScript code outside of a web browser. This allows you to build and run both front-end and back-end applications using JavaScript code on your PC or server.

Popular front-end web frameworks that use Node.js include Angular and React. Remember that Node.js can also be used to develop back-end or full-stack applications. Popular back-end frameworks that use Node.js include Express.js, Meteor.js, Nest.js, and Hapi.js.

Related Topics: Front End And Back End Web Development: Which Path Is Right For You?

Because of the great popularity of JavaScript for programming, Node.js has become an important component in software development and Linux administration for servers running JavaScript applications.

Install NVM on Linux

Installing NVM on Linux is pretty straightforward. Open your Terminal and run the following command.

curl -o- | Bash

The above command runs a script that downloads and installs NVM. In addition, a profile for NVM is set in your environment variable. In this case it is .bashrc File as you can see from the installation output below.

The environment variable file is in one of the following locations: ~ / .bash_profile, ~ / .zshrc, ~ / .profile, or ~ / .bashrc depending on the Linux distribution you are using.

Check the installation

Note: Before you can check whether the installation was successful, close your current terminal and open a new terminal window. Alternatively, you can open another terminal window by pressing Ctrl + Alt + T. on the keyboard.

In the new terminal window, you can verify that NVM has been installed successfully by running the following command.

Command -v nvm

If all went well, the output from the above command will be nvm As shown below.

To check the version of NVM installed on your PC, you can do the following.

nvm -v

Install Node.js

Installing Node.js with NVM is very easy. For example, to install the latest version of Node.js, you can run the following command:

NVM installation node

To install a specific version of Node.js, you can run the nvm command in the following format:

Version number of the NVM installation

For example, to install Node.js version 14.15.4:

nvm install 14.15.4

Node.js version 14.15.4 is an LTS version of Node.js.

If you've come this far and given the two commands above, congratulations! You have two different versions of Node.js installed on your PC or server.

Choosing which version of Node.js. to use

If you have multiple versions of Node.js installed, you can easily choose which version of Node.js you want to use. For example, to use the recently installed version 14.15.4, you can run the following command.

nvm use 14.15.4

To see the list of Node.js versions installed on your PC, you can run the following command.

nvm ls

The output of the listing is similar to the following. The currently active version is also highlighted.

To list all versions of Node.js available for installation, you can run:

nvm ls-remote

Uninstall Node.js.

Uninstalling a version of Node.js through NVM is very easy. For example, to uninstall version 14.15.4 installed above:

Uninstall nvm v14.15.4

get help

Simply enter the following command to learn more about NVM commands or for help:

nvm -h

You can also visit NVM's official GitHub page which is well documented.

Node.js management simplified

This guide shows you how to install Node Version Manager (NVM) to make managing and installing Node.js easier. If you have projects that use different versions of Node.js, NVM is the tool for you. It will just make your life easier.

Reusability is one of the most important programming paradigms that everyone should follow. Fortunately, there is an easy way to create reusable code in JavaScript using design patterns.

How to create reusable code in JavaScript using design patterns

If you know how to use design patterns, you can use reusable code in JavaScript. Here's what you need to know.

Continue reading

About the author

Mwiza Kumwenda
(5 articles published)

Mwiza is a professional developer of software and writes extensively on Linux and front-end programming. Some of his interests include history, economics, politics, and enterprise architecture.

By Mwiza Kumwenda

Subscribe to our newsletter

Sign up for our newsletter to receive tech tips, reviews, free e-books, and exclusive offers!

One more step …!

Please confirm your email address in the email we just sent you.

Leave a Reply

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