Master the installation and uninstallation of Node.js and npm on Debian system
This article provides three ways to install Node.js and npm on Debian systems: use the default Debian repository, NodeSource repository, and Node Version Manager (NVM). Each method includes step-by-step instructions and instructions on how to verify that the installation is successful. In addition, this article also introduces how to uninstall Node.js and npm from the Debian system. The specific steps depend on the installation method (default Debian repository or NVM). Node Version Manager (NVM) is especially useful for developers who need to manage multiple Node.js versions and switch easily. This article provides instructions for installing different Node.js versions using NVM and switching between installed versions.
Install Node.js and npm on Debian system
Are you ready to build a scalable web application using Node.js on your Debian system? This guide walks you through the entire process of installing Node.js on Debian, ensuring you have the right tools. We will also cover how to uninstall Node.js and npm.
Method 1: Use the default Debian warehouse to install
Debian repository is a good starting point for developers looking for a stable Node.js version. Using an official warehouse guarantees reliable installation, allowing you to focus on your project without worrying about compatibility issues.
Update the package list: Run sudo apt update
Update the package list to get the latest version of Node.js in the repository.
Install Node.js and npm: Run sudo apt install nodejs
Install Node.js and its dependencies. After the installation is complete, Node.js is installed on your system. Then run sudo apt install npm
to install npm (Node.js package manager). npm is used to install Node.js modules and packages.
Verify installation: Run the node -v
and npm -v
commands to view installed Node.js and npm versions. The displayed version number confirms that Node.js and npm are installed and can be used normally.
Method 2: Use NodeSource warehouse to install
NodeSource repository is a better choice for developers who need the latest version and better compatibility. It offers multiple Node.js versions, giving you access to the latest versions and features.
Add NodeSource Repository: Follow the instructions in the NodeSource GitHub repository to your Debian system.
Install Node.js and npm: Run sudo apt install nodejs
Install Node.js and npm from the NodeSource repository.
Verify installation: Run the node -v
and npm -v
commands to verify installation.
Method 3: Use Node Version Manager (NVM) to install
Node Version Manager (NVM) is the ideal solution for developers who need to manage multiple Node.js versions and switch easily.
Install NVM on Debian:
nvm use [版本号]
(replace "[version number]" with the required Node.js version). Install the Node.js version using NVM: Use the nvm install [版本号]
to install the required Node.js version using the nvm ls
command. Run
Switch between active Node.js versions:nvm use [版本号]
Use the nvm alias default [版本号]
to switch to the installed version. Use the
Uninstall Node.js and npm
Uninstall from Debian repository:sudo apt remove nodejs
If you are installing Node.js and npm from the default Debian repository, run the node -v
command to uninstall. Run the npm -v
and
Uninstall using NVM:nvm uninstall [版本号]
If you use NVM installation, run the
Summary
This guide describes different ways to install and uninstall Node.js and npm on Debian systems, including using the default Debian repository, NodeSource repository, and Node Version Manager (NVM). Now you can use these knowledge and tools to develop your Node.js project!
The above is the detailed content of Quick Tip: How to Install Node.js on Debian. For more information, please follow other related articles on the PHP Chinese website!