The Front-End
Package Managers
Node.js & npm

Installing Node.js and npm

Node.js and npm are essential tools in modern web development. Node.js is an open-source JavaScript runtime environment that allows server-side execution of JavaScript code. It features an asynchronous and event-driven architecture, making it suitable for scalable and high-performance applications. npm, the Node Package Manager, complements Node.js by facilitating the management of project dependencies and providing access to a vast ecosystem of open-source packages. Together, they enable developers to build cross-platform applications efficiently, leveraging JavaScript both on the client and server sides.

  1. Setting up Node.js and npm on Different Platforms
  2. Checking the Installation and Versions
  3. Verifying Node.js Installation
  4. Verifying npm Installation
  5. Checking Node.js and npm Versions

Setting up Node.js and npm on Different Platforms

Windows:

  1. Download Installer:

  2. Run Installer:

    • Double-click the downloaded file to run the installer.
    • Follow the installation prompts, accepting the default settings.
  3. Verify Installation:

    • Open a Command Prompt or PowerShell.
    • Type the following commands to check Node.js and npm versions:
      node -v
      npm -v

macOS:

  1. Using Homebrew:

    • Open Terminal.
    • Install Homebrew (if not installed) by running:
      /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    • Install Node.js and npm:
      brew install node
  2. Verify Installation:

    • In Terminal, check Node.js and npm versions:
      node -v
      npm -v

Linux (Ubuntu/Debian):

  1. Using Package Manager:

    • Open Terminal.
    • Update package lists:
      sudo apt update
    • Install Node.js and npm:
      sudo apt install nodejs npm
  2. Verify Installation:

    • In Terminal, check Node.js and npm versions:
      node -v
      npm -v

Checking the Installation and Versions

Verifying Node.js Installation:

To check if Node.js is installed, open a terminal and run:

node -v

This command should print the installed version of Node.js.

Verifying npm Installation:

To check if npm is installed, open a terminal and run:

npm -v

This command should print the installed version of npm.

Checking Node.js and npm Versions:

To check the versions of both Node.js and npm in one command, use:

node -v && npm -v

This will print the versions of Node.js and npm on separate lines.

Example Output:

v14.17.5
7.24.0

Installing Node.js and npm provides a robust foundation for building JavaScript applications. Verifying the installation and versions ensures that your development environment is configured correctly, allowing you to leverage the latest features and enhancements in your projects.