Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

Empowering you to understand your world

How To Install Node.js

By Nicholas Brown – Follow me on Twitter.

Node.js Tutorials: How To Install Node.js On Ubuntu Or Debian

You can install Node.js on Ubuntu using one of the following methods:

How To Install Node.js Using The APT Package Manager

You can install Node.js using the APT package manager using the following command. This will install the latest version supplied by the Ubuntu package maintainers, which may be older than the latest version. If you want to install the latest version, scroll down further to see how to download it directly from the Node.js website.

sudo apt install nodejs

After typing that you should see ‘the following NEW packages will be installed’, and ‘nodejs’ should be among them. It will also suggest ‘npm’, which is useful to have as well. Press ‘Y’ and enter to install it.

How To Update Node.js Using The Package Manager

You can update Node.js using the Ubuntu or Debian package manager by typing the following command:

sudo apt update
sudo apt --only-upgrade install nodejs

How To Install The Latest Version Of Node.js On Ubuntu Or Debian

If the Ubuntu repositories don’t include the latest versions of Node.js, you can get the binary from the Node.js download page and extracting it. You can also use the Node Version Manager (NVM). You will be provided with the option to select the long-term support (LTS) version or the current version if downloading the binary from the website. The LTS version is recommended because it is more stable.

To install Node.js using NVM or install multiple versions of Node.js, please follow the instructions in the NVM article to install NVM, and then run the following command with the version of Node.js you’d like to install:

nvm install v20.2.0

How To Update Node.js Using NVM

To update your Node.js version using NVM, you’d type the following command, which installs the latest version. The second line will alternately install the latest LTS version:

nvm install node
nvm install node --lts

If you want to set up a repository that does have the latest version so that it is automatically updated, you can use Nodesource.

How To Check Node.js Version

You can check the version of Node.js your system is using with the following command:

node -v

How To Run Node.js

You can run Node.js by itself by typing ‘nodejs’ or ‘node’ on some installations, or you can start your project along with it as shown below:

nodejs yourapp.js

How To Run Node.js Using NVM

You can run a Node.js app from NVM using the following command (change 20.2.0 to the version you have):

nvm run 20.2.0 yourapp.js
Subscribe to our newsletter
Get notified when new content is published