How to install npm and node.js on windows & mac
February 4, 2025
Node.js is a popular runtime environment that lets developers build scalable network applications. npm (Node Package Manager) is bundled with Node.js and is widely used to manage project dependencies. This guide will walk you through the installation process on Windows and macOS.
What is Node.js and npm?
Before diving into the installation process, let’s quickly understand:
- Node.js: A JavaScript runtime built on Chrome’s V8 engine, enabling JavaScript to run outside a browser.
- npm: A package manager for Node.js, allowing developers to install and manage libraries and dependencies.
Node.js and npm Installation on Windows
Step 1: Download Node.js Installer
- Visit the official Node.js website: https://nodejs.org.
- You’ll see two versions:
- LTS (Long-Term Support): Recommended for most users.
- Current: Includes the latest features (may not be stable for production).
- Click the LTS version for better stability.
Step 2: Install Node.js
- Locate the downloaded .msi file and double-click it to run.
- Follow the installer steps:
- Accept the license agreement.
- Choose the installation folder (default is recommended).
- Ensure the option "Add to PATH" is checked during the installation process.
- Click Install and wait for the process to complete.
Step 3: Verify Installation
After installation:
- Open the Command Prompt (or PowerShell).
- Type the following commands to check if Node.js and npm are installed:
If you see a version number, it means that Node.js has been installed successfully.
Step 4: Update npm (Optional)
You can update npm to the latest version by running:
This command updates npm globally to the latest version available.
Node.js and npm Installation on macOS
Option 1: Node.js and npm Installation on macOS Using the Installer
Step 1: Download Node.js Installer
- Visit the official Node.js website: https://nodejs.org.
- You’ll see two versions:
- LTS (Long Term Support): Recommended for most users.
- Current: Includes the latest features (may not be stable for production).
- Click the LTS version for better stability.
Step 2: Install Node.js
- Open the downloaded .pkg file.
- Follow the instructions in the installer wizard.
- Verify the installation by opening the Terminal and running:
If you see a version number, it means that Node.js has been installed successfully.
Option 2: Node.js and npm Installation on macOS Using Homebrew (Recommended)
Homebrew is a package manager for macOS that simplifies installations.
Step 1: Install Homebrew
If you don’t have Homebrew installed, run this command in the Terminal:
Step 2: Install Node.js
- Run the following command to install Node.js (includes npm):
2. Verify the installation:
Step 3: Update npm (Optional)
If you want to update npm to the latest version:
Conclusion:
Installing npm and Node.js on Windows and Mac is a crucial step for any JavaScript developer. By following the steps and tips provided, you can effortlessly set up your development environment and start building powerful JavaScript applications. Remember to stay updated with the latest versions, leverage community resources, and continuously optimize your workflow to make the most out of these essential tools.