node sudo nvm

Step 1: Install Node Version Manager (NVM)

NVM is a version manager for Node.js that allows you to easily switch between different versions of Node.js on your system. To install NVM, you can use the following command:

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

This command downloads and executes a script that installs NVM on your system.

Step 2: Close and reopen your terminal

After installing NVM, you need to close and reopen your terminal for the changes to take effect. This ensures that the NVM command is available in your terminal session.

Step 3: Verify the installation

To verify that NVM is installed correctly, you can run the following command:

command -v nvm

If NVM is installed correctly, this command should print out nvm. If you see any output, it means that NVM is not installed or not configured correctly.

Step 4: Install a specific version of Node.js

Once NVM is installed, you can use it to install a specific version of Node.js. For example, to install Node.js version 14.x, you can use the following command:

nvm install 14

This command downloads and installs the specified version of Node.js on your system.

Step 5: Use the installed version of Node.js

After installing a version of Node.js, you can use it by running the following command:

nvm use 14

This command sets the installed version of Node.js as the active version for your current terminal session.

Step 6: Verify the Node.js installation

To verify that Node.js is installed correctly, you can run the following command:

node --version

This command should print out the version of Node.js that you installed.

Step 7: Optional - Set the default Node.js version

If you want to set a default version of Node.js to be used across all terminal sessions, you can use the following command:

nvm alias default 14

This command sets the specified version of Node.js as the default version.

Step 8: Optional - Update NVM

To update NVM to the latest version, you can use the following command:

nvm install --lts

This command installs the latest LTS (Long-Term Support) version of Node.js using NVM.

That's it! You have now installed and configured NVM, and installed a specific version of Node.js using NVM.