How To Install Node via Ubuntu Terminal
Install nvm and start using Node.js on Ubuntu
Photo by Gabriel Heinzer on Unsplash
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.js, 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)
Want to Connect? ๐ค
If you found the information in this tutorial useful please subscribe on Hashnode, follow me on Twitter, and/or subscribe to my YouTube channel.
Thanks for reading!