A Beginner's Guide to Installing Node.js
Leroy · 4 Oct 2023 · 1 min read
Installing Node.js
Node.js is a JavaScript runtime for running code outside the browser. I use nvm, the Node Version Manager, to install and switch between Node versions.
Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
Restart your terminal or reload your shell config:
source ~/.bashrc
Install a Node Version
nvm install --lts
This installs the latest LTS release. You can also install a specific version:
nvm install 18
nvm install 20
Switch Between Versions
nvm use 20
Set a default:
nvm alias default 20
Verify
node --version
npm --version
Global Packages (Optional)
npm install -g nodemon
That's it. Node.js and npm are ready.