Debian is a stable and secure Linux distribution widely used in server and desktop environments. Nodejs is a popular JavaScript runtime environment used to build efficient network applications. In this article, we will discuss how to install Nodejs using the Debian system.
Step 1: Update the system
It is best to update your Debian system before installing any new software packages. Execute the following command in the terminal window:
sudo apt-get update sudo apt-get upgrade
Step 2: Install Nodejs
In Debian, Nodejs can be installed in various ways. In this tutorial, we will use the NodeSource package library. This software package library is very suitable for solving the problem of old versions of Nodejs in the Debian official repository.
To install NodeSource, you need to enter the following command in the terminal:
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
This will automatically set up the Nodejs APT repository. Install Node.js from the repository and execute the following command:
sudo apt-get install -y nodejs
This command will download and install Nodejs and all its dependencies.
Step 3: Check if Nodejs has been successfully installed
After installation is complete, you can use the following command to check if Nodejs has been successfully installed:
node -v
If you see an output similar to the following in the terminal window, it indicates that Nodejs has been successfully installed:
v14.15.4
Step 4: Install NPM
NPM is the package manager for Node.js, used to manage various packages and dependencies used in JavaScript applications. After Nodejs installation is completed, NPM should also have been installed together. You can check if the npm installation was successful by executing the following command:
npm -v
If NPM is not automatically installed, you can manually install it using the following command:
sudo apt-get install -y npm
Step 5: Upgrade NPM
If you have already installed NPM, please make sure to upgrade to the latest version. Execute the following command:
sudo npm install npm@latest -g
Step 6: Install the global NPM module
After installing and using Nodejs and NPM, you can install global NPM modules, which are very useful for building and deploying applications. Execute the following command in the terminal window to install the global module:
sudo npm install -g express pm2
This will download and install a large number of global NPM modules such as Express and PM2.
Copyright Description:No reproduction without permission。
Knowledge sharing community for developers。
Let more developers benefit from it。
Help developers share knowledge through the Internet。
Follow us
2023-12-04