How to manage multiple Node versions on Ubuntu 22.04?

rajamuhammadasher

Raja Muhammad Asher

Posted on November 18, 2022

How to manage multiple Node versions on Ubuntu 22.04?

Node Version Manager allows you to quickly install and use different versions of node via the command line.

NVM Install & Update Script

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

Troubleshooting

After running the install script, if you

get nvm: command not found

or see no feedback from your terminal after you type

command -v nvm

, simply close your current terminal, open a new terminal, and try verifying again. Alternatively, you can run the following command for the different shells on the command line:

$ source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

List of installed Node versions

$ nvm ls
Enter fullscreen mode Exit fullscreen mode

Check current Node version

$ nvm current
Enter fullscreen mode Exit fullscreen mode

List available LTS versions of Node.js

$ nvm ls-remote
Enter fullscreen mode Exit fullscreen mode

Install the Node version

$ nvm install <NODE_VERSION>
Enter fullscreen mode Exit fullscreen mode

Select the Node version to use

$ nvm use <NODE_VERSION>
Enter fullscreen mode Exit fullscreen mode

Uninstall the Node version

$ nvm uninstall <NODE_VERSION>
Enter fullscreen mode Exit fullscreen mode

Set Node Version as default

$ nvm alias default <NODE_VERSION>
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
rajamuhammadasher
Raja Muhammad Asher

Posted on November 18, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related