ubuntu install nodejs npm

WBOY
Release: 2023-05-27 20:47:05
Original
1759 people have browsed it

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
Copy after login

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 -
Copy after login

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
Copy after login

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
Copy after login

You should see output similar to the following:

v14.17.3
Copy after login

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
Copy after login

This command will install the latest version of npm.

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

npm -v
Copy after login

You should see output similar to the following:

7.20.3
Copy after login

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!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template