Comment installer Node.js et npm sur Windows, macOS et Linux (Guide 2025)

August 23, 2024

Introduction

Node.js is a powerful JavaScript runtime environment that enables you to run JavaScript code on the server side. npm (Node Package Manager) is the default package manager for Node.js and is essential for managing JavaScript packages and dependencies. In this guide, we’ll walk you through the steps to install Node.js and npm on Windows, macOS, and Linux.

1. Installation de Node.js et de npm sous Windows

Étape 1 : Télécharger Node.js

  1. Visitez le site Site officiel de Node.js.
  2. Téléchargez le programme d'installation Windows (.msi) pour la version LTS (Long Term Support).

Étape 2 : Installer Node.js

  1. Run the downloaded .msi file.
  2. Follow the installation prompts, ensuring that you check the box to include npm in the installation.
  3. Click “Next” and “Install” to complete the setup.

Étape 3 : Vérifier l'installation

  1. Ouvrez l'invite de commande.
  2. Type node -v to check the Node.js version.
  3. Type npm -v to check the npm version.

2. Installation de Node.js et de npm sur macOS

Étape 1 : Installer Node.js via Homebrew

  1. Terminal ouvert.
  2. Installer Homebrew if you haven’t already by running:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  3. Install Node.js and npm with:
    brew install node

Étape 2 : Vérifier l'installation

  1. In Terminal, type node -v to check the Node.js version.
  2. Type npm -v to check the npm version.

Méthode alternative : Télécharger à partir du site web

  1. Visitez le site Site officiel de Node.js.
  2. Download the macOS installer and run the .pkg file.
  3. Suivez les instructions pour terminer l'installation.

3. Installation de Node.js et de npm sous Linux

Étape 1 : Mise à jour de l'index de votre paquet

  1. Terminal ouvert.
  2. Exécutez la commande suivante pour mettre à jour l'index du paquet :
    sudo apt update

Étape 2 : Installer Node.js et npm

  • Pour les distributions basées sur Debian/Ubuntu:
    sudo apt install nodejs npm
  • Pour les distributions basées sur CentOS/RHEL:
    sudo yum install nodejs npm
  • Pour Fedora:
    sudo dnf install nodejs npm

Étape 3 : Vérifier l'installation

  1. In Terminal, type node -v to check the Node.js version.
  2. Type npm -v to check the npm version.

Méthode alternative : Installation via Node Version Manager (nvm)

  1. Install nvm (Node Version Manager) by running:
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
  2. Load nvm:
    source ~/bashrc
  3. Install Node.js using nvm:
    nvm install node
  4. Verify by typing node -v and npm -v.

Conclusion

Installing Node.js and npm is straightforward, whether you’re on Windows, macOS, or Linux. By following this guide, you’ll have Node.js and npm up and running in no time, ready for your development projects. With Noeud.js installed, you’re all set to explore the world of server-side Javascript et commencez à construire des applications.