0
0
NodejsHow-ToBeginner · 3 min read

How to Install npm in Node.js: Simple Steps

npm is automatically installed when you install Node.js. To get npm, download and install the latest Node.js from the official website, and npm will be ready to use in your command line.
📐

Syntax

npm is included with Node.js installation. You do not install npm separately. After installing Node.js, you can check npm version with the command below.

bash
npm --version
Output
9.6.7
💻

Example

This example shows how to install Node.js, then verify npm is installed and check its version.

bash
1. Go to <a href="https://nodejs.org/" target="_blank" rel="noopener noreferrer">https://nodejs.org/</a> and download the latest LTS version.<br>2. Run the installer and follow the steps.<br>3. Open your terminal or command prompt.<br>4. Type <code>node --version</code> to check Node.js.<br>5. Type <code>npm --version</code> to check npm.<br><br># Example commands:<br>node --version<br>npm --version
Output
v20.5.1 9.6.7
⚠️

Common Pitfalls

Common mistakes when installing npm:

  • Trying to install npm separately without Node.js. npm comes bundled with Node.js.
  • Using outdated Node.js installers that may not include the latest npm.
  • Not restarting the terminal after installation, so commands are not recognized.
  • Confusing npm with node commands.

Always install the latest Node.js from the official site to get npm automatically.

bash
Wrong approach:
npm install -g npm

Right approach:
# Install Node.js from https://nodejs.org/
# npm is included automatically
📊

Quick Reference

StepCommand / ActionDescription
1Download Node.jsGo to https://nodejs.org/ and download the latest LTS version
2Run InstallerFollow the installation wizard to install Node.js and npm
3Verify Node.jsRun node --version in terminal
4Verify npmRun npm --version in terminal
5Use npmRun npm commands like npm install package-name

Key Takeaways

npm is installed automatically with Node.js; no separate installation needed.
Download the latest Node.js from the official website to get npm.
Verify installation by running npm --version in your terminal.
Restart your terminal after installation to ensure commands work.
Avoid trying to install npm separately without Node.js.