a computer screen with a bunch of text on it

Photo by Nick Karvounis on Unsplash

💻 Tech & Devices15 min read📊 Easy

How to Install npm: Quick & Easy Guide

Learn how to quickly install npm (Node Package Manager) on Windows, macOS, and Linux. Get started managing JavaScript packages for your projects today.

Quick Summary

Installing npm (Node Package Manager) is a fundamental step for any JavaScript developer, as it enables efficient management of project dependencies and tools. Since npm is typically bundled with Node.js, the installation process involves setting up Node.js itself. This guide provides a straightforward approach to get npm running on your system, preparing you for successful development. For a more in-depth look, refer to our [How to Install npm: A Comprehensive Guide](/en/how-to-install-npm).

Jump to steps ↓

Advertisement

🛒 What You Need

  • Internet connection
  • Command Line Interface (CLI) or Terminal
  • Administrator/sudo privileges

📋 Steps

1

Check for Existing Node.js and npm Installation

Before proceeding with a new installation, it's wise to check if Node.js and npm are already present on your system. Open your terminal or command prompt and run node -v and npm -v. If versions are returned, they are installed. If you encounter "command not found" errors, you'll need to install them.

💡 Tip: If you see old versions, consider updating them or performing a fresh install if issues arise.
2

Download the Node.js Installer

npm comes bundled with Node.js. To install both, navigate to the official Node.js website (nodejs.org) in your web browser. You'll typically see two download options: an LTS (Long Term Support) version and a Current version. The LTS version is recommended for most users due to its stability and long-term support. Download the appropriate installer for your operating system (Windows, macOS).

3

Install Node.js (and npm) on Windows and macOS

Once the Node.js installer is downloaded, run it. For Windows, double-click the .msi file and follow the prompts, accepting the license agreement and default installation options. On macOS, double-click the .pkg file and proceed through the installation wizard. Both installers automatically include npm.

💡 Tip: It's generally safe to accept the default installation path unless you have specific reasons to change it.

Advertisement

4

Install Node.js (and npm) on Linux (Ubuntu/Debian)

For Linux distributions like Ubuntu or Debian, it's recommended to use the NodeSource repositories for the latest stable versions. First, update your package list: sudo apt update. Then, install curl if you don't have it: sudo apt install curl. Next, add the NodeSource PPA and install Node.js (which includes npm): curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - followed by sudo apt install nodejs. This method ensures you get the official Node.js binaries.

💡 Tip: For other Linux distributions, consult the official Node.js installation guide or your distribution's documentation.
5

Verify the Installation

After the installation completes, close and reopen your terminal or command prompt to ensure that your system's PATH environment variable is updated. Then, run node -v and npm -v again. You should now see the installed versions of Node.js and npm, confirming a successful setup.

💡 Tip: If you still encounter "command not found," try restarting your computer, especially on Windows.
7

Run a Basic npm Command Test

To confirm npm is fully functional, try using a simple command. For example, you can initialize a new project by navigating to an empty directory and running npm init -y. This will create a package.json file, which is fundamental for managing project dependencies with npm.

💡 Tip: Explore the npm documentation for more advanced commands like npm install or npm run