Come installare Node.js e npm su Windows, macOS e Linux (guida 2025)

23 agosto 2024

introduzione

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. Installazione di Node.js e npm su Windows

Passo 1: Scaricare Node.js

  1. Visita il sito Sito ufficiale di Node.js.
  2. Scaricare il programma di installazione di Windows (.msi) per la versione LTS (Long Term Support).

Passo 2: installare 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.

Fase 3: Verifica dell'installazione

  1. Aprire il Prompt dei comandi.
  2. Type node -v to check the Node.js version.
  3. Type npm -v to check the npm version.

2. Installazione di Node.js e npm su macOS

Passo 1: installare Node.js tramite Homebrew

  1. Terminale aperto.
  2. Installare 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 installare node

Fase 2: Verifica dell'installazione

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

Metodo alternativo: Scaricare dal sito web

  1. Visita il sito Sito ufficiale di Node.js.
  2. Download the macOS installer and run the .pkg file.
  3. Seguire le indicazioni per completare l'installazione.

3. Installazione di Node.js e npm su Linux

Passo 1: Aggiornare l'indice dei pacchetti

  1. Terminale aperto.
  2. Eseguite il seguente comando per aggiornare l'indice del pacchetto:
    sudo apt update

Passo 2: Installare Node.js e npm

  • Per le distribuzioni basate su Debian/Ubuntu:
    sudo apt install nodejs npm
  • Per le distribuzioni basate su CentOS/RHEL:
    sudo yum installare nodejs npm
  • Per Fedora:
    sudo dnf installare nodejs npm

Fase 3: Verifica dell'installazione

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

Metodo alternativo: Installazione tramite 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 installare il nodo
  4. Verify by typing node -v and npm -v.

Conclusione

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 Node.js installed, you’re all set to explore the world of server-side JavaScript e iniziare a costruire potenti applicazioni.