Introducción
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. Instalación de Node.js y npm en Windows
Paso 1: Descargar Node.js
- Visite el Sitio web oficial de Node.js.
- Descargue el instalador de Windows (.msi) para la versión LTS (Long Term Support).
Paso 2: Instalar 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.
Paso 3: Verificar la instalación
- Abra el símbolo del sistema.
- Type node -v to check the Node.js version.
- Type npm -v to check the npm version.
2. Instalación de Node.js y npm en macOS
Paso 1: Instalar Node.js mediante Homebrew
- Terminal abierto.
- Instale Elaboración casera 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 install nodo
Paso 2: Verificar la instalación
- In Terminal, type node -v to check the Node.js version.
- Type npm -v to check the npm version.
Método alternativo: Descargar desde el sitio web
- Visite el Sitio web oficial de Node.js.
- Download the macOS installer and run the .pkg file.
- Siga las instrucciones para completar la instalación.
3. Instalación de Node.js y npm en Linux
Paso 1: Actualizar el índice de paquetes
- Terminal abierto.
- Ejecute el siguiente comando para actualizar el índice de paquetes:
sudo apt update
Paso 2: Instalar Node.js y npm
- Para distribuciones basadas en Debian/Ubuntu:
sudo apt install nodejs npm - Para las distribuciones basadas en CentOS/RHEL:
sudo yum install nodejs npm - Para Fedora:
sudo dnf install nodejs npm
Paso 3: Verificar la instalación
- In Terminal, type node -v to check the Node.js version.
- Type npm -v to check the npm version.
Método alternativo: Instalación a través del Gestor de versiones de nodos (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 install node
Verify by typing node -v and npm -v.
Conclusión
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 Nodo.js installed, you’re all set to explore the world of server-side javascript y empezar a construir aplicaciones.