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
- Visita il sito Sito ufficiale di Node.js.
- Scaricare il programma di installazione di Windows (.msi) per la versione LTS (Long Term Support).
Passo 2: installare Node.js
- Run the downloaded .msi file.
- Follow the installation prompts, ensuring that you check the box to include npm in the installation.
- Click “Next” and “Install” to complete the setup.
Fase 3: Verifica dell'installazione
- Aprire il Prompt dei comandi.
- Type node -v to check the Node.js version.
- Type npm -v to check the npm version.
2. Installazione di Node.js e npm su macOS
Passo 1: installare Node.js tramite Homebrew
- Terminale aperto.
- Installare Homebrew if you haven’t already by running:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install Node.js and npm with:
brew installare node
Fase 2: Verifica dell'installazione
- In Terminal, type node -v to check the Node.js version.
- Type npm -v to check the npm version.
Metodo alternativo: Scaricare dal sito web
- Visita il sito Sito ufficiale di Node.js.
- Download the macOS installer and run the .pkg file.
- Seguire le indicazioni per completare l'installazione.
3. Installazione di Node.js e npm su Linux
Passo 1: Aggiornare l'indice dei pacchetti
- Terminale aperto.
- 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
- In Terminal, type node -v to check the Node.js version.
- Type npm -v to check the npm version.
Metodo alternativo: Installazione tramite Node Version Manager (nvm)
- Install nvm (Node Version Manager) by running:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
- Load nvm:
source ~/bashrc
- Install Node.js using nvm:
nvm installare il nodo
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.