
It will also add the GPG key of the new repository automatically.

The script will add a new repository in the source list directory (/etc/apt/). The above command will download and start running the installation script. If you want to install Node.js version 19, you can replace setup_18.x with setup_19.x. Now you can use the following command: curl -fsSL | sudo -E bash. First, install Curl on Ubuntu: sudo apt install curl Let’s say you want to install Node.js version 18. You need to specify which major version of Node.js you want to install. The output should be like this: Node.js and NPM installed versions

Once installed, you verify it by checking the installed version of Node.js and npm with this command: node -version I recommend installing npm as well because you’re going to need it anyway. So all you need to do is to open a terminal and use the following command: sudo apt install nodejs npm Method 1: Install Node.js and npm on Ubuntu using the official repositoryĪs I said earlier, Node.js is available on Ubuntu. This tutorial will discuss all three methods of installing Node and npm. Using Node Version Manager (NVM): This is a per-user installation of Node.js, where you can switch between multiple versions.Using NodeSource repository: Slightly more complicated but you can choose to install from the currently available Node versions.Using Ubuntu’s official repository: Easy to install using apt but might have an older version.There is also Node Version Manager for advanced users. To get the latest Node version, you can add the official Node repository. However, it may not always be the latest version. Node.js is available in the Ubuntu repository and you can easily install it with a few commands. If you want to install Node.js on Ubuntu Linux, you’re in luck. Node and npm are often installed and used together. So you can use one in your application without needing to rewrite the entire thing all on your own.

It’s an open-source library of Node.js packages. Node.js (or Node) is supported by npm (Node.js Package Manager). You can quickly develop and deploy web apps with it. Node.js has become a major part of the modern web.
