Let’s be real: the command line can feel intimidating, like walking into a library where everyone whispers in code. But I promise, this is simpler than assembling IKEA furniture. We’ll use the package manager, which is just a polite robot that does the heavy lifting for you.
First, open your terminal. You can find it by pressing Ctrl+Alt+T on your keyboard. Don’t worry, nothing will explode. We’re just going to have a little chat with your system.
Step 1: Update Your Guest List
Think of your Ubuntu system’s list of software sources like a party guest list. Sometimes you have old, outdated addresses. So we refresh it. Type this and hit Enter:
sudo apt update
Your computer will download a list of what’s new. It’s like checking the fridge before you go grocery shopping. A little planning makes everything smoother.
Step 2: Install the Curl Tool
Next, we need a tiny tool called curl. It’s like a little retriever dog that fetches data from the internet for us. If you don’t have it, install it with this command:
sudo apt install curl -y
How to Install Node.js and NPMon Linux - (1 command)
The -y flag just tells the computer “yes, I’m sure” so it doesn’t keep asking for confirmation. It’s the digital equivalent of saying “just do it, I trust you.”
Step 3: Welcome the NodeSource Team
Now, we’re going to add a special address to our party list. This address comes from a group called NodeSource, who keep the latest version of Node ready. Paste this whole line carefully:
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
This command is like giving your computer a friend’s phone number. It’s saying, “Hey, go fetch the latest Node.js setup from this trusted source, please.”
Step 4: The Magic Install
Take a deep breath. This is the best part. Now we simply ask our system to install Node.js:
sudo apt install nodejs -y
You’ll see a bunch of text scroll by. That’s just the robot working hard for you. When it finishes, the terminal returns to its silent, waiting state. That’s it. You did it.
Step 5: Check Your Work (Like a Pro)
Always test your new appliance, right? If you bought a toaster, you’d pop a slice of bread in. Let’s check Node works perfectly. Type:
node -v
How to Install Node.JS on Ubuntu 18.04 - LinuxForDevices
Your terminal will spit back a version number, like v20.x.x. That’s your trophy. You now have Node.js living on your Ubuntu machine. Give yourself a little fist bump.
You can also check npm (Node Package Manager), which comes with it. Type:
npm -v
This is your app store. It lets you download millions of free code libraries, from tools that make emojis work to ones that control robots. It’s the real power under the hood.