Or copy link
Copy link
Node.js is a runtime environment that enables the execution of JavaScript code on the server side. It is designed to be lightweight and efficient, using the V8 JavaScript runtime. While Node.js is compatible with various operating systems, including Linux, its primary purpose is not confined to any specific OS.
The main goal of Node.js is to facilitate the development of scalable and high-performance server-side applications. It is particularly well-suited for creating web applications and APIs, employing an event-driven, non-blocking I/O model that enhances its efficiency in handling numerous concurrent connections.
In this article, we will be providing an in-depth detail on how to install Node.js on Ubuntu 22.04.
Also, read Install Node.js on CentOS 7
Start by updating the package lists to fetch the latest information about available software.
sudo apt update && sudo apt upgrade
The next step involves installing Node.js using the package manager. This ensures a hassle-free installation and easy future updates.
sudo apt install nodejs
Verify that Node.js has been successfully installed by checking its version.
node -v
The primary purpose of a PPA is to offer a convenient way for users to access software that may not be included in the default Ubuntu repositories. It enables developers to deliver the latest versions of their software, experimental features, or custom builds directly to users who choose to add the PPA to their system. This decentralized approach enhances the flexibility and responsiveness of the Ubuntu ecosystem, as users can easily obtain and install software that aligns with their specific needs or preferences.
However, it’s essential to exercise caution when adding PPAs, as they are maintained by individuals or groups outside the official Ubuntu development team. Users should only trust PPAs from reliable sources to ensure the security and stability of their system.
We need to first make sure that curl is installed as it is needed to access the desired PPA repository on Ubuntu 22.04:
$ sudo apt install curl
Next, we need to execute the below-mentioned commands to successfully install the Node.js:
sudo apt-get update && sudo apt-get install -y ca-certificates curl gnupg curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg NODE_MAJOR=20 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 sudo apt-get update && sudo apt-get install nodejs -y
These commands will update your package lists, install necessary dependencies, retrieve the GPG key for the Node Source repository, add the repository to your system, and finally install Node.js. Make sure to execute these commands in the order provided.
Unleash the power of Ubuntu VPS
Get the reliability of the world’s most popular Linux distro and the flexibility of a virtual server. Enjoy blazing-fast speeds and low latency.
NVM allows you to easily install and switch between different versions of Node.js on your system. This is particularly useful when you’re working on projects that require specific Node.js versions, as NVM enables you to manage those versions seamlessly.
With NVM, you can install multiple Node.js versions side by side, and switch between them based on the requirements of different projects. This flexibility is valuable because different projects may depend on different Node.js versions due to compatibility or feature requirements.
$ curl curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
The command downloads the NVM installation script from the specified URL using curl and then immediately executes the script using bash. The purpose is to automate the installation of NVM on your system. Once NVM is installed, you can use it to manage and install different versions of Node.js.
To list all versions of Node.js we can use the below command:
$ source ~/.bashrc $ nvm list-remote
Next, we need to scroll down to find the latest available versions of Node.js and then install any of them as per our requirements:
$ nvm install v21.6.2
After installing Node.js, it is recommended to install npm (Node Package Manager) as well if you already didn’t. The NPM is the default package manager for Node.js, which is a JavaScript runtime that allows you to execute JavaScript code on the server side. It is used to manage and install packages (libraries and tools) for Node.js projects.
$ sudo apt install npm
Node.js is a handy tool for running JavaScript on servers. It’s lightweight, works on different systems, and is great for building fast and scalable server applications. The article explains three ways to install Node.js on Ubuntu 22.04. Method 1 uses the default package manager for a straightforward setup. Method 2 talks about adding a repository for more flexibility but advises caution. Method 3 introduces NVM, a tool that lets you easily manage different Node.js versions. The article also touches on where Node.js shines, like making web servers, APIs, real-time apps, microservices, and build tools. Overall, Node.js is a solid choice for various server-side needs.
If you’re a developer diving into app development, ensure your hosting setup can handle Node.js demands. Ultahost offers reliable NodeJS hosting with dedicated resources for guaranteed speed and stability, ideal for resource-intensive tasks.
Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine. It allows developers to run JavaScript on the server-side, enabling the creation of scalable and high-performance web applications.
Ubuntu 22.04 is a Long Term Support (LTS) version, ensuring stability and security updates. Installing Node.js on this platform provides a reliable environment for developing and running JavaScript-based server applications.
Open a terminal and type node -v. If Node.js is installed, it will display the installed version. If not, you can install it using the following steps.
In the terminal, run node -v for Node.js and npm -v for npm. This will display the installed versions.
npm -v
Python is a powerful and versatile programming language...
Restarting Ubuntu after updates, troubleshooting, or ro...
If you’re a software developer, you know the importan...
OpenJDK the Open Java Development Kit is a free and ope...
Odoo, the powerful open-source enterprise resource plan...
phpPgAdmin is a free, open-source web-based tool that s...
Save my name, email, and website in this browser for the next time I comment.
Δ