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

  1. Download the installer: Visit the official Node.js website (https://nodejs.org/en/) and download the latest LTS (Long-Term Support) version for Windows.
  2. Run the installer: Double-click the downloaded installer file.
  3. Follow the prompts: The installer will guide you through the installation process. By default, npm will be installed along with Node.js.
  4. 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

  1. Download the installer: Visit the official Node.js website (https://nodejs.org/en/) and download the latest LTS version for macOS.
  2. Run the installer: Double-click the downloaded installer file.
  3. Follow the prompts: The installer will guide you through the installation process. By default, npm will be installed along with Node.js.
  4. 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:

  1. Download the installer: Visit the official Node.js website (https://nodejs.org/en/) and download the latest LTS version for Linux.
  2. Extract the installer: Extract the downloaded file.
  3. 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.