GNU/Linux Ubuntu Adding Node JS Repository
Hi! The Guide shows you Step-by-step How to Add the Node JS Repository for Ubuntu-Based GNU/Linux Systems.
And with this Node JS Repo Setup you’ll be able to Install both : 16.x LTS, 18.x LTS, 20.x LTS, 21.x, and Current.
For more insight see the official: NodeJs Repository Documentation.
Finally, this Node JS Ubuntu Repository is valid also for:
- Linux Mint
- Zorin OS
- Lubuntu
- Elementary OS
- Kde Neon
- Pop_OS!
- Xubuntu
- Linux Lite
- Bodhi
- Puppy
- Kubuntu
- LXLE
- Trisquel
- Voyager
- feren OS
- Peppermint
- Linux Ultimate Edition
(You may only need to find the Corresponding Ubuntu Parent Release)
-
1. Terminal Getting-Started Guide
How to QuickStart with Command Line on Ubuntu GNU/Linux
First Update the Apt Repo Sources with:
sudo apt update
Authenticate with the User Admin Pass.
If Got “User is Not in Sudoers file” then see: How to Enable sudo. -
2. Installing Dependencies
Then to Install Required Software
Run:sudo apt install -y ca-certificates curl gnupg
Authenticate with the User Admin Pass.
If Got “User is Not in Sudoers file” then see: How to Enable sudo. -
2. Adding GPG Key
Now to Add Node.js Signing Key
First, make the Target Directory with:sudo mkdir -p /etc/apt/keyrings
And then to Setup it:
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
-
3. Setting Up NodeJS Repository
Then Add Node JS Apt Repository
Especially relevant: Node.js 18+ is supported only on Ubuntu 20.04+ based Systems.
Now for Node 20 Set the Env. Var. as:NODE_MAJOR=20
Possibly amend “NODE_MAJOR” Variable with that of your choice.
And then run:echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
For Nodejs 16, and 18, change the NODE_MAJOR correspondly.
Last, to Update the Apt Sources:sudo apt update
-
4. Installing NodeJS
Now to Install NodeJS for Linux
Simply play:sudo apt install nodejs
-
5. Getting Started Node Js
How to Get Started with NodeJs on Ubuntu GNU/Linux