Node.js is a powerful, open-source JavaScript runtime environment that allows you to run JavaScript code outside the browser — making it ideal for building fast and scalable web applications. If you’re working on Ubuntu 22.04 dedicated server and want to get started with Node.js, this guide will walk you through the process of installing it step by step.
Method 1: Install Node.js from Ubuntu Repository
This is the simplest method, but it may not provide the latest version.
Step 1: Update Your Package Index
Step 2: Install Node.js
Step 3: Install npm (Node Package Manager)
Step 4: Verify Installation
If you need the latest version of Node.js, consider the next method using NodeSource.
Method 2: Install Latest Node.js via NodeSource
NodeSource provides up-to-date Node.js packages.
Step 1: Download and Run the NodeSource Script
For example, to install Node.js v20.x:
Step 2: Install Node.js
This will install both node and npm.
Step 3: Verify Installation
Method 3: Install Node.js Using NVM (Node Version Manager)
This method is recommended if you want to manage multiple versions of Node.js.
Step 1: Install NVM
Then restart your shell or run:
Step 2: Install the Latest Node.js Version
Or install a specific version:
Step 3: Use a Specific Version
Step 4: Set Default Node Version
Conclusion
Installing Node.js on Ubuntu 22.04 is easy, and you have several options depending on your needs:
Use the Ubuntu repository for a quick install.
Use NodeSource for the latest version.
Use NVM to manage multiple versions.
Whichever method you choose, you’ll be ready to start building powerful applications with Node.js in no time.


