Web development and Tech news Blog site. WEBISFREE.com

HOME > webdevetc

Changing Node and NPM version using nvm.

Last Modified : 03 Mar, 2023 / Created : 03 Mar, 2023
View Count
Matching the version of Node (npm) with the development environment is very important in Node development. If the currently installed Node version does not match the version required for developing a web application, you can use nvm to change and modify it.

# Changing node version using nvm

Before using nvm, it was very complicated and difficult to switch the Node version, as it required deleting or changing the version of Node. For this reason, a simpler method was needed, and after using nvm, changing the Node version became very easy and simple. Now, let's learn how to install and use nvm.

@ What is nvm?
Let's first briefly understand nvm. nvm is the abbreviation of Node Version Manager, which is a tool for managing the version of Node. nvm (node version control), which can manage nodejs versions and select the desired version, is one of the most commonly used essential utilities, and it is very easy to use and change the desired node and npm versions. The main functions of nvm are as follows.

  • Ability to use the desired node version
  • Install and select multiple node versions

If you use nvm, you don't need to install and delete the required version each time, and you can easily switch between multiple desired versions. Especially when developing multiple projects that use different node versions at the same time in a local development environment, it can be very useful. Now, let's learn how to install nvm.

! How to install nvm

You can install nvm using wget or curl. Choose one of the two methods to install. The current latest version is 0.39.1.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.39.1/install.sh | bash

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.39.1/install.sh | bash

We will install the above method as the desired method. After installation is complete, nvm can be used from the command line. To check the available node versions, use the nvm ls command. Further important commands will be discussed below.

! nvm usage and commands

To check the available version first, enter the ls command as follows:
> nvm ls

default -> v14 (-> v14.19.3)
node -> stable (-> v18.6.0) (default)
stable -> 18.6 (-> v18.6.0) (default)
lts/fermium -> v14.20.0 (-> N/A)
lts/gallium -> v16.16.0

At this time, available versions are displayed, and you can choose one of them to install or install an uninstalled version.

@ nvm version installation and how to use
Let's find out how to install and use the desired node version. First, to install, type "install", and to use, type "use".
> nvm install <node version>
> nvm use <node version>

To install and use node version 16, you can enter the following commands. First, you need to install it.
> nvm install v16.0.0

Now using node v16.0.0 (npm vx.x.x)
Creating default alias: default -> v16.0.0

To use it after installation, please enter as follows.
> nvm use v16.0.0

Now, if you check the node version, you can confirm that the version has been changed.
> node --version


By the way, if you want to install the LTS version, please use the --lts option as follows.
> nvm install --lts

We briefly looked into how to use nvm to change Node versions.


[NodeJS] Resolving the issue of not being able to retrieve the request body in nodejs express when making post and patch requests through ajax.


Solving Browser Cookie Size Error 400 Issue