Step-by-Step Guide to Install NPM and Node.js on Mac and Windows

To install Node.js and NPM on Windows or Mac, first download the latest Node.js installer from the official Node.js website. On Windows, run the .msi file and follow the setup wizard, accepting the license agreement and default install settings. On Mac, download and run the .pkg installer, again accepting all defaults.

After installation completes, verify it was successful by opening a terminal and typing node -v to print the Node.js version installed. And type npm -v to check the NPM version. Both commands should return installed version numbers without errors. Node.js and NPM are now set up properly.

Additional steps like configuring your default Node.js version or enabling npm autocompletion can further customize the environment. But Node.js and NPM will now be available to use on Windows or Mac for installing packages globally or locally within projects.

Using Node.js and NPM Offers a Variety of Benefits:

Use JavaScript on the server: Node.js enables full-stack JS development using a single programming language.

  • High-Performance Scalability: Node.js’s asynchronous, event-driven architecture of Node.js makes it lightweight, efficient, and optimal for real-time web apps.
  • Active Open Source Community: As an open source project maintained by the Node.js Foundation and thousands of contributors, new features, updates, and fixes are constantly added to Node.js.
  • Access To Numerous Libraries: With the npm registry, developers can access over 1.3 million reusable JavaScript packages covering a wide range of functions.
  • Cross-Platform Support: Node.js and NPM can be installed across various systems like Windows, Linux, and macOS.

This comprehensive guide will cover step-by-step instructions for installing the latest versions of Node.js and NPM on both Windows and Mac systems.

Prerequisites or Requirements Before Installing Node.js and NPM

Before installing Node.js and NPM, ensure your system meets the following requirements:

  • Operating System:
  • Windows 7, 8.1, or 10
  • macOS X Yosemite or later
  • 64-bit OS architecture
  • At least 4GB RAM
  • Minimum of 200MB of free disk space
  • Working internet connection for downloading packages and dependencies

Supported CPU platforms include IA-32, x64, ARMv6, ARMv7, ARMv8, and x86-64. With these prerequisites satisfied, you are ready to install Node.js and NPM.

A Step-by-Step Guide to Install Node.js and NPM on Windows

The easiest way to install Node.js on Windows is using the official installer available from the Node.js website. It will also install NPM automatically as NPM is distributed with Node.js.

Alternatively, you can use a version manager like nvm-windows to control multiple Node.js versions.

Deciding which Node.js version to install

The current Long-Term Support (LTS) version of Node.js is v18.x, recommended for most users. The latest end-of-life schedule and release details are on the Node.js Release page.

Check this before downloading a Node.js installer to ensure your project works smoothly for an extended period, as LTS versions include critical bug fixes and security updates.

Using the Node.js Windows Installer

Head to, and you’ll find installers for various Node.js versions under Windows downloads.

Download the LTS build recommended for most users. It will typically be node-vXX.XX.X-x64.msi for 64-bit machines or node-vXX.XX.X-x86.msi for 32-bit, where XX.XX.X represents the Node.js version.

Once downloaded, run the installer (.msi file) and follow these steps:

  1. Start the installer and click Next to advance through the initial wizard prompts.
  2. Review and accept the license agreement before proceeding.
  3. No changes are required on the Custom Setup screen, so leave the default setup. Click Next.
  4. Select the destination location to install Node.js and NPM. By default, this is C:\Program Files\nodejs. Click Next.
  5. No action is needed on the Custom Setup screen listing components to install, as npm will be installed automatically with Node.js. Click Next.
  6. Confirm the settings look correct on the final review screen. Click Install to run the installation.
  7. When the installation is complete, check the final dialog box confirming Node.js and NPM were installed and click Finish.

Node.js is now installed and ready to use! The installer adds npm and node to your system PATH, making them globally accessible.

Steps to Install Node.js with nvm-windows

nvm-windows is an alternative Node.js version manager for Windows. It allows installing and running multiple versions of Node.js on the same Windows machine.

Follow these steps to install Node.js using nvm-windows:

  1. Download the latest nvm-windows installer from
  2. Run the downloaded nvm-windows installer and accept the license agreement in the wizard. Select all options on the installer screens.
  3. Open a new command prompt window to complete nvm configuration. Run the command nvm so it can modify environment variables.
  4. Now install a Node.js version by running:
nvm install 18.12.1

Replace 18.12.1 with your desired Node.js version.

  1. Verify Node.js installed correctly with:
nvm use 18.12.1
node -v

It will switch to using v18.12.1 and return the Node.js version installed.

How to Verify Node.js Installation

Open a command prompt window and enter node -v to print the Node.js version installed:

$ node -v

It checks that Node.js was correctly installed.

You can also run a simple Node.js script to verify everything works.

Create a file test.js with this code:

console.log("Node.js works!");

Save the file then from the terminal run:

node test.js

It should print Node.js works! Indicating Node.js can properly execute JavaScript code.

Step-by-Step Guide to Install Global NPM Modules on Windows

NPM modules can be installed locally within a project or globally to make them accessible from anywhere.

Here’s how to install modules globally on Windows:

  1. Open the command prompt running as administrator. Hit Start and search cmd. Right-click Command Prompt and Select Run as administrator.
  2. Install a module globally using npm install -g <module-name>.

For example:

npm install -g live-server
  1. Close and reopen the command prompt for changes to take effect before using the installed module.
  2. Verify successful installation by checking the module version:
live-server -v

Now, you can access the installed live-server module globally from the command line.

Step-by-Step Guide to Install Node.js and NPM on Mac

MacOS comes preinstalled with a compatible version of OpenSSL that is required for Node.js. So, generally, an additional installation isn’t needed, but you can still install the latest or Long Term Support (LTS) versions using the Node.js installer binaries.

How to Check Existing Node.js Installation

Open the terminal and run node -v to check if Node.js already exists:

node -v

If the node isn’t recognized, Node.js needs to be installed. If your macOS has an older Node.js version, you may upgrade for improved performance and features.

Using the Node.js Mac Installer

Like Windows, head to, and under the MacOS downloads section, find installers for various Node.js versions.

Download your chosen installer, node-vXX.XX.X.pkg, where XX.XX.X represents the Node.js version number.

Once downloaded, double-click the .pkg file to launch the installation process and follow the prompts:

  1. Start the Node.js installer, review the license agreement, and accept it to proceed.
  2. Select the disk where Node.js should be installed, typically Macintosh HD. Click Continue.
  3. On the default view, click Install to proceed with the standard Node.js and NPM installation to /usr/local/bin/node.
  4. Enter password when prompted to provide administrator privileges for modifying system paths. Click Install Software to run the installer.
  5. Once complete, the installer will automatically add Node.js and npm to your system PATH. Click Close when done.

Node.js is now installed and ready for use! The accessible node and npm commands can run JavaScript, compile ES6/ES7, and install NPM modules globally or locally.

Steps for Installing Node.js with nvm

The Node Version Manager nvm allows you to install multiple self-contained Node.js versions and switch between them. To install nvm:

  1. Open the terminal and enter the cURL install script:
curl -o- | bash
  1. Close the terminal entirely and reopen it to apply the nvm changes.
  2. Verify nvm installation worked:
command -v nvm
  1. Now install the Node.js version, for example, v18.12.1:
nvm install 18.12.1
  1. Set this version to use when opening a new terminal:
nvm use 18.12.1
  1. Check correct Node.js version is active:
node -v

nvm allows seamless Node.js version switching.

How to Verify Node.js Installation

Confirm Node.js is installed and works properly by checking the version:

node -v

You’ll see the Node.js version number if the installation succeeds.

You should also test by running a basic JavaScript script.

Create a file test.js containing:

console.log("Node works!");

Save them from the terminal run:

node test.js

It should print Node works! Indicating Node.js runs JavaScript correctly.

A Step-by-Step Guide to Install Global NPM Modules on Mac

NPM modules helpful across projects can be installed globally on Mac:

  1. Open the terminal as administrator privileges are needed:
sudo -s
  1. Install your chosen package globally with npm install -g
npm install -g http-server
  1. Hit enter when asked for the password to permit modifying system paths
  2. Check the module installed globally by running:
http-server -v

You can now access the HTTP-server module system-wide.

Validating the Installations

To validate that Node.js works as expected, try running basic Node.js scripts or sample projects you create.

Test script examples:
// Import File System module
const fs = require('fs');
// Import http module
const http = require('http');
// Start http server
http.createServer((req, res) => {
fs.readFile('test.txt', (err, data) => {
res.writeHead(200, {'Content-Type': 'text/html'});

This script imports core Node.js modules, reads test.txt file data, and then starts a server to output the contents on port 8000.

Save the test file and run scripts from the terminal to verify seamless Node.js usage.

You should also initialize sample projects using npm init to test installing local packages, create an app structure, and run the projects smoothly.

Additionally, install some common useful NPM packages locally like:

npm install express
npm install mongoose
npm install react

Then, build test files requiring these packages to confirm package imports work correctly within sample Node.js apps.

Troubleshooting Common Issues for Installation Node.js and NPM on Windows and Mac

Here are solutions for some commonly faced verification errors and installation issues:

Issue/Error Solution
Node not recognized as a command. Ensure Node.js is added to the system PATH. Reboot the machine after installation to refresh environment variables.
Permission errors on MacOS while using npm Prefix commands with sudo or follow steps to fix NPM permissions
Proxy/corporate network connectivity issues Set proxy via terminal export commands on Mac/Linux or proxy settings on Windows.
Various failed install errors Ensure prerequisites are met; check against Node.js support resources or forums.

Concluding Thoughts on Installing Node.js and NPM on Windows and Mac

Installing Node.js and the NPM package manager opens immense opportunities for full-stack JavaScript development. Whether looking to start with server-side scripting in Node.js or tapping into the vast array of JavaScript libraries, first configure these core tools.

Now that you have installed the current Long-Term Support and latest Node.js runtimes on your Windows or Mac system, you can start developing apps, scripts, microservices, and other solutions using JavaScript end-to-end!

Check the numerous learning resources available, including official Node.js docs, community guides, online courses, and more to take your Node.js mastery to new heights.

Amelie Lamb

Amelie Lamb

Amelie Lamb is an experienced technical content writer at who specializes in distilling complex software topics into clear, concise explanations. She has a talent for taking dense technical jargon and making it engaging and understandable for readers through her informative, lively writing style.

Table of Contents