Home > Article > Web Front-end > apt install nodejs
aptInstall Node.js
Node.js is an open source, cross-platform, runtime environment that uses an event-driven, non-blocking I/O programming model. It was introduced by Ryan Dahl in 2009 Created in year.
On Ubuntu or Debian systems, we can use the apt package manager to install Node.js. This article will introduce how to install Node.js using apt package manager on Ubuntu or Debian system.
Before installing Node.js, we need to update the system's package cache. Enter the following command in the terminal:
sudo apt update
On Ubuntu or Debian systems, we can use the NodeSource repository to install Node.js. We need to add the NodeSource repository to our system. Enter the following command in the terminal:
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
In the above command, 12.x represents the Node.js version we want to install. If you need to install another version, please replace 12.x with another version number.
Next, we can use the following command to install Node.js:
sudo apt install -y nodejs
The above command will install nodejs and npm.
After completing the installation, we can use the following command to verify whether Node.js has been installed successfully:
node -v
If After successful installation, it will output the version number of Node.js. For example: v12.8.3.
We can also use the following command to verify whether npm has been installed successfully:
npm -v
It will output the version number of npm. For example: 6.10.3.
After completing the installation of npm, we can use the following command to update npm to the latest version:
sudo npm install -g npm
Next, we can use The following command is used to verify whether npm has been updated to the latest version:
npm -v
If the update is successful, it will output the latest version number of npm.
Summary
It is very convenient to install Node.js using apt. You can complete the installation process by entering a few commands in the terminal. I hope this article can provide you with some valuable information to facilitate the installation and configuration of Node.js on your own machine.
The above is the detailed content of apt install nodejs. For more information, please follow other related articles on the PHP Chinese website!