Inleiding
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. Node.js en npm installeren op Windows
Stap 1: Node.js downloaden
- Bezoek de Officiële website van Node.js.
- Download het Windows-installatieprogramma (.msi) voor de LTS-versie (Long Term Support).
Stap 2: Node.js installeren
- 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.
Stap 3: Controleer de installatie
- Open Opdrachtprompt.
- Type node -v to check the Node.js version.
- Type npm -v to check the npm version.
2. Node.js en npm installeren op macOS
Stap 1: Node.js installeren via Homebrew
- Terminal openen.
- Installeer Zelfbouw 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 installeren node
Stap 2: Controleer de installatie
- In Terminal, type node -v to check the Node.js version.
- Type npm -v to check the npm version.
Alternatieve methode: Downloaden van de website
- Bezoek de Officiële website van Node.js.
- Download the macOS installer and run the .pkg file.
- Volg de aanwijzingen om de installatie te voltooien.
3. Node.js en npm installeren op Linux
Stap 1: Werk uw pakketindex bij
- Terminal openen.
- Voer de volgende opdracht uit om de pakketindex bij te werken:
sudo apt update
Stap 2: Node.js en npm installeren
- Voor Debian/Ubuntu-gebaseerde distributies:
sudo apt installeer nodejs npm - Voor CentOS/RHEL-gebaseerde distributies:
sudo yum installeer nodejs npm - Voor Fedora:
sudo dnf installeer nodejs npm
Stap 3: Controleer de installatie
- In Terminal, type node -v to check the Node.js version.
- Type npm -v to check the npm version.
Alternatieve methode: Installeren via 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 node installeren
Verify by typing node -v and npm -v.
Conclusie
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 en begin met het bouwen van krachtige toepassingen.