How to Install Node via Ubuntu Terminal
Install nvm and start using Node.js on Ubuntu
Introduction
This article provides the commands needed to install Node.js on Ubuntu via nvm. Nvm (aka Node Version Manager) is a handy tool that makes it easy to download and switch between versions of Node.js.
Steps
Make sure your system is up to date.
sudo apt update && sudo apt upgrade
Install curl via apt install. Note it’s important to install curl via apt instead of snap. For more info see this Stack Overflow post.
sudo apt install curl
Download and run the install script for nvm.
wget https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh
bash install.sh
Verify that nvm was installed properly
nvm -v
# 0.39.2
Finally, install node via nvm install.
nvm install --lts
Bonus
If your project depends on a specific version of node, create .nvmrc file in the project’s root.
echo "18" > .nvmrc # default to version 18
You can switch to the version specified by a project with nvm use.
nvm use
# Found '/home/bobby/Desktop/github/node-dump-syms/.nvmrc' with version <18>
# Now using node v18.12.1 (npm v8.19.2)
Thanks for reading!
Want to Connect? If you found the information in this tutorial useful please subscribe on Medium, follow me on X, and/or subscribe to my YouTube channel.