Node.js is a JavaScript runtime environment that allows you to execute JavaScript code outside of a web browser. npm (Node Package Manager) is a package manager for Node.js, used to install, manage, and share JavaScript packages.
Installing on Windows
- Download the installer: Visit the official Node.js website (https://nodejs.org/en/) and download the latest LTS (Long-Term Support) version for Windows.
- Run the installer: Double-click the downloaded installer file.
- Follow the prompts: The installer will guide you through the installation process. By default, npm will be installed along with Node.js.
- Verify the installation: Open a command prompt or terminal and type node -v and npm -v. You should see the installed versions of Node.js and npm.
Installing on macOS
- Download the installer: Visit the official Node.js website (https://nodejs.org/en/) and download the latest LTS version for macOS.
- Run the installer: Double-click the downloaded installer file.
- Follow the prompts: The installer will guide you through the installation process. By default, npm will be installed along with Node.js.
- Verify the installation: Open a terminal and type node -v and npm -v. You should see the installed versions of Node.js and npm.
Installing on Linux
There are multiple ways to install Node.js and npm on Linux. Here are a few common methods:
Using a package manager:
- Debian/Ubuntu:
Bash
sudo apt install nodejs npm
- Fedora/CentOS:
Bash
sudo dnf install nodejs npm
- Arch Linux:
Bash
sudo pacman -S nodejs npm
Using the Node.js installer:
- Download the installer: Visit the official Node.js website (https://nodejs.org/en/) and download the latest LTS version for Linux.
- Extract the installer: Extract the downloaded file.
- Run the installer: Navigate to the extracted directory and run the installer script (e.g., ./configure, make, sudo make install).
Verify the installation:
Once the installation is complete, open a terminal and type node -v and npm -v. You should see the installed versions of Node.js and npm.