Home > Web Front-end > JS Tutorial > Quick Tip: How to Install Node.js on Debian

Quick Tip: How to Install Node.js on Debian

Jennifer Aniston
Release: 2025-02-08 13:09:13
Original
269 people have browsed it

Quick Tip: How to Install Node.js on Debian

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.

  1. Update the package list: Run sudo apt update Update the package list to get the latest version of Node.js in the repository.

  2. 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.

  3. 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.

  1. Add NodeSource Repository: Follow the instructions in the NodeSource GitHub repository to your Debian system.

  2. Install Node.js and npm: Run sudo apt install nodejs Install Node.js and npm from the NodeSource repository.

  3. 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.

  1. Install NVM on Debian:

    • Go to the NVM GitHub repository to download the installation script.
    • Open the terminal and navigate to the directory where the script is located.
    • Run the script to install NVM.
    • Restart the terminal.
    • Activate NVM with nvm use [版本号] (replace "[version number]" with the required Node.js version).
  2. Install the Node.js version using NVM: Use the nvm install [版本号] to install the required Node.js version using the nvm ls command. Run

    to view all Node.js versions that have been installed.
  3. Switch between active Node.js versions:nvm use [版本号] Use the nvm alias default [版本号] to switch to the installed version. Use the

    command to set the default version.

Uninstall Node.js and npm

  1. 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

    commands to verify that the uninstallation is successful.
  2. Uninstall using NVM:nvm uninstall [版本号] If you use NVM installation, run the

    command to uninstall a specific version of Node.js.

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!

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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template