Home  >  Article  >  Web Front-end  >  ubuntu install nodejs npm

ubuntu install nodejs npm

WBOY
WBOYOriginal
2023-05-27 20:47:051695browse

Installing Node.js and npm on an Ubuntu system is very simple. This article details how to install Node.js and npm on an Ubuntu system.

Step 1: Update the package list

First, before installing any new software, we should update the package list of the Ubuntu system to ensure that the software we install is the latest version.

Run in the terminal using the following command:

sudo apt update

When prompted, enter your password and press Enter to confirm.

Step 2: Install Node.js

Now, let’s install Node.js.

The Node.js package in Ubuntu's official software repositories is outdated. Therefore, we will use the Node.js official source to get the latest version. Add the official GPG key to your system using the following command:

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

This will automatically add the Node.js 14.x sources to your system's list of repositories.

Now, we can use the following command to install Node.js:

sudo apt install -y nodejs

This command installs the Node.js installation package and npm package together.

After the installation is complete, we can use the following command to check the Node.js version:

node -v

You should see output similar to the following:

v14.17.3

Step 3: Installation npm

When we install Node.js, npm is also installed. But sometimes we need to install a specific version of npm. In this case, we can use the following command to install npm:

sudo npm install npm -g

This command will install the latest version of npm.

You can also check the npm version using the following command:

npm -v

You should see output similar to the following:

7.20.3

Now, you are successfully on your Ubuntu system Node.js and npm installed. Use these commands in the terminal to ensure the installation is correct and start developing your next web application!

The above is the detailed content of ubuntu install nodejs npm. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn