TABLE OF CONTENT

Share this article

Introduction

If you’re stepping into web development, then it’s very likely that you’re going to hear about Node.js at the first go. And why? Because Node is the backbone of the modern JavaScript development experience and allows you to execute JavaScript outside the browser. Be it front-end applications, back-end services, or full-stack solutions, Node.js is your platform of choice. Paired with NPM, it hugely provides ease in dependency management and easy access to thousands of open-source packages that simplify and speed up your workflow.

So, how do you get Node.js and NPM installed on your PC?

That’s what this guide is for. Whether you’re on a Windows machine or a Mac, this step-by-step detailed guide will take you through the installation process, show you how to verify that everything is working and help you troubleshoot common problems.

Why Install Node.js and NPM?

Node.js is not just a programming tool; it is the foundation of many modern web technologies. If you develop websites, mobile applications, or even desktop applications using JavaScript, Node.js gives you a powerful environment in which you can execute your code directly on your machine outside the browser. Now, that’s revolutionary because in the past, people used JavaScript in a web browser. Now, with Node.js, you can use JavaScript for server-side development, then have one language dominate both front-end and back-end development.

At the same time, NPM makes it easy to download, distribute, and manage libraries or packages your project needs. You can install tools, like React, Express.js, or even libraries that are more utility in nature, like Lodash, with a single command. It also manages versioning and the dependencies of your projects so you never miss a beat.

Here’s just a few reasons why you should have Node.js and NPM installed.

  • JavaScript Everywhere: Node.js puts JavaScript onto the server for the first time. You can now build full-stack applications in one language.
  • Fast Development: Node.js’s asynchronous architecture makes applications run extremely fast and scalable. This makes great sense for apps in which real-time communication is essential, such as chat applications, gaming servers, and APIs.
  • Massive Ecosystem: NPM offers the largest open-source libraries ecosystem. No matter what you’re building, there probably is a package that can make a job much easier.
  • Seamless project management: NPM makes it easy to manage the dependencies and packages available in your project. All that you need to do is open up the terminal and run a simple command called npm install.

 

By downloading Node.js and NPM, you will be setting an excellent basis for the development of your web application. In building up interactive websites or mobile applications, you’ll probably need to develop back-end services by yourself using these tools as the bedrock of your development environment. Let’s get started on how we can get them installed on both Windows and Mac systems.

Understanding Node.js and NPM

Before moving forward with instructions on how to install Node.js and NPM, we should know what the tools in question are and why they are such significant components in today’s development.

What is Node.js?

It basically becomes the runtime environment to run JavaScript on your computer, aside from the web browser. Traditionally, JavaScript was known to be used exclusively with a web browser for front-end code having to do with DOM manipulation, event handling, or API calls. However, with Node.js, JavaScript could now run on the server side and let you build back-end services, APIs, and full-stack applications using one language—JavaScript.

What is NPM?

NPM, short for Node Package Manager, is installed with Node.js. NPM lets you install, update and manage the libraries or packages used in any Node.js application. Accessing reusable code and tools through a vast repository by NPM also helps streamline and speed up development.

NPM is one of the largest package ecosystems in the world, with millions of open-source packages available. No matter what you need for a project, whether to work with HTTP requests or to operate with databases, or even to construct user interfaces, there is surely something that suits your needs on NPM.

Installing Node.js and NPM on Windows

If you’re using Windows, installing Node.js and NPM on your machine is quite a straightforward process. This section will take you through every step-from downloading the installer to checking that it’s installed properly, and even includes some troubleshooting tips.

Step 1: Download Node.js Installer

  1. Go to the Node.js Official Website
    First, open your web browser and navigate to the official Node.js website at https://nodejs.org. This is where you can download the installer.

  2. Choose Between LTS and Current Versions
    On the website’s download page, you’ll see two main options:

    • LTS (Long-Term Support): This is the recommended version for most users because it’s more stable and receives regular security updates. It’s ideal if you’re building production applications.
    • Current: This version includes the latest features and updates but may not be as stable as LTS. It’s suitable if you want to experiment with cutting-edge features.
  3. For most purposes, it’s better to choose the LTS version unless you have a specific need for the newest features.

  4. Download the Installer for Windows
    Once you’ve chosen your version, click the corresponding Windows Installer link. The download will start, and you’ll get a .msi file, which is the installer for Windows.

Step 2: Install Node.js and NPM

Now that you’ve downloaded the installer, follow these steps to install Node.js and NPM on your system.

  1. Run the Installer
    Locate the .msi file that you just downloaded (it’s likely in your Downloads folder). Double-click the file to open it. This will launch the Node.js Setup Wizard.

  2. Accept the License Agreement
    The first screen you’ll see is the License Agreement. Read through it, and if you agree, click the “I accept the terms in the License Agreement” checkbox. Then click Next to proceed.

  3. Choose the Installation Folder
    The next screen will prompt you to select the folder where Node.js will be installed. By default, the installer will use the C:\Program Files\nodejs\ directory, which works for most users. If you prefer a different location, you can change it here. Once done, click Next.

  4. Select Features to Install
    On this screen, you’ll see a list of features to install. The most important option here is the checkbox labeled “Add to PATH”. Ensure this option is checked. This adds Node.js and NPM to your system’s PATH, allowing you to run them from the command line without navigating to their install directory.

    There may also be options to install additional tools, but these are usually not necessary for a basic setup.

  5. Begin Installation
    After reviewing your selections, click Install. The installer will now begin copying the necessary files and configuring your system. This may take a few minutes, so be patient.

  6. Complete the Installation
    Once the installer finishes, you’ll see a confirmation screen. Click Finish to close the setup wizard. Congratulations! Node.js and NPM are now installed on your Windows machine.

Step 3: Verify the Installation

Now that Node.js and NPM are installed, it’s important to verify that everything is working correctly. To do this, you’ll use the Command Prompt.

  1. Open Command Prompt
    Press Win + R, type cmd, and hit Enter. This will open the Command Prompt window, which you’ll use to check your Node.js and NPM installations.

  2. Check Node.js Version
    To verify that Node.js has been installed correctly, type the following command in the Command Prompt:

    node -v

    This command will display the version number of Node.js installed on your system. If it outputs a version number (e.g., v18.16.0), Node.js has been installed successfully.

  3. Check NPM Version
    Now, let’s check if NPM was installed alongside Node.js. Type this command:

    npm -v

    This should return the version number of NPM (e.g., 9.6.4). If you see a version number, NPM was installed correctly.

If both commands output version numbers, your installation was successful, and you’re ready to start using Node.js and NPM on your Windows machine.

Step 4: Install Packages Using NPM

Now that you’ve got Node.js and NPM installed, let’s test out NPM by installing a package. NPM allows you to install thousands of open-source libraries to help with your development. One of the most popular packages is Express.js, a framework for building web applications.

  1. Install Express.js
    In the Command Prompt, type the following command to install Express:

    npm install express


    NPM will download and install Express along with its dependencies. After the installation is complete, you can find the node_modules folder in the directory where you ran the command. This folder contains Express and its dependencies.

  2. Check Installed Packages
    To verify that Express was installed, you can list all installed packages by typing:

    npm list


    This will display a list of all the packages that have been installed in your project.

Troubleshooting Common Issues on Windows

Even though installing Node.js and NPM is usually smooth, you might encounter a few issues. Here are some common problems and their solutions:

  1. Node or NPM Commands Not Found
    If after installation, you try to run the node -v or npm -v commands, and you get an error like command not recognized, it’s likely that Node.js wasn’t added to your system’s PATH during installation.

    Solution: You can manually add Node.js to your PATH.

    • Right-click on This PC or My Computer, and select Properties.
    • Click on Advanced system settings, and then click on Environment Variables.
    • Find the Path variable under System Variables, click Edit, and add the path to your Node.js installation (e.g., C:\Program Files\nodejs\).
    • Restart your computer and try running the commands again.
  2. Permission Issues When Installing Packages Globally
    Sometimes, you might encounter permission errors when trying to install packages globally using the -g flag (e.g., npm install -g nodemon). This happens because Windows requires administrator privileges to modify certain directories.

    Solution: You can either:

    • Run the Command Prompt as an administrator by right-clicking on the Command Prompt icon and selecting Run as administrator.
    • Or, change NPM’s default directory to avoid permission issues. To do this:
      • Open the Command Prompt.
      • Run the following commands to create a new directory and tell NPM to use it:

        mkdir ~/.npm-global npm config set prefix ‘~/.npm-global’

      • Then, add this new directory to your PATH:

        setx PATH “%PATH%;%USERPROFILE%\.npm-global\bin”

      • Restart your Command Prompt, and you should now be able to install global packages without needing admin privileges.

Installation Failed
Sometimes, the installation might fail due to corrupt files or pre-existing installations that conflict with the new one.

Solution: Uninstall any existing Node.js versions from your system by going to Control Panel > Uninstall a Program. Look for Node.js, select it, and uninstall it. After that, restart your computer and try the installation again.

Installing Node.js and NPM on Mac

If you’re using a Mac, you have several ways to install Node.js and NPM. The most popular methods are using the official installer from Node.js’s website or using Homebrew, a package manager for macOS that simplifies software installations.

Both methods are straightforward and effective, so we’ll go through each one in detail.

Method 1: Installing Node.js and NPM via the Official Installer

This is the simplest way to install Node.js and NPM on your Mac. The Node.js website offers an installer specifically for macOS.

Step 1: Download Node.js Installer

  1. Visit the Node.js Official Website
    Open your browser and go to https://nodejs.org. You’ll see two versions available for download:

    • LTS (Long-Term Support): This version is recommended for most users as it’s stable and receives regular updates.
    • Current: This version includes the latest features but may not be as stable as LTS. It’s typically used by developers experimenting with new features.
  2. For most users, it’s better to choose the LTS version unless you have a specific reason to use the Current version.

  3. Download the macOS Installer
    Once you’ve selected the LTS version (or Current, if that’s what you prefer), click the download button for macOS. This will download a .pkg file, which is the macOS installer for Node.js.

Step 2: Install Node.js and NPM

Now that you have the .pkg installer file downloaded, follow these steps to complete the installation:

  1. Open the .pkg File
    Go to your Downloads folder and locate the .pkg file you just downloaded. Double-click it to open the installer.

  2. Follow the Installation Wizard
    The installer will guide you through the setup process.

    • Accept the License Agreement when prompted.
    • Choose the installation location (the default location is typically fine).
    • Click Install to begin the installation. You might be prompted to enter your admin password to allow the installation.
  3. Complete the Installation
    Once the installation process is finished, click Close to exit the installer. Node.js and NPM are now installed on your Mac.

Step 3: Verify the Installation

After installation, you’ll want to make sure everything is working correctly. You can verify the installation by running a few commands in Terminal.

  1. Open Terminal
    Press Command + Space, type Terminal, and hit Enter. This will open a new terminal window.

  2. Check Node.js Version
    To verify that Node.js is installed, type the following command and press Enter:

    node -v

    This will display the version number of Node.js installed on your Mac. If you see something like v18.16.0, Node.js is installed successfully.

  3. Check NPM Version
    Next, let’s verify that NPM is installed by typing this command:

    npm -v

    This command should return the NPM version number (e.g., 9.6.4). If you see a version number, then NPM was installed successfully alongside Node.js.

Step 4: Install Packages with NPM

To confirm that NPM is working properly, you can try installing a package. Let’s install Express.js, a popular Node.js framework for building web applications.

  1. Install Express
    In the terminal, type the following command:

    npm install express


    NPM will download and install the Express package and its dependencies. After the installation, you’ll see a new node_modules folder in the directory where you ran the command, containing the installed package.

  2. Check Installed Packages
    To see a list of installed packages, type:

    npm list

    This command will display a list of packages that have been installed in your project.

Troubleshooting Common Issues on Mac

While the installation process is usually smooth, you may encounter some issues. Here are a few common problems and how to solve them:

  1. Node or NPM Commands Not Found
    If you try to run the node -v or npm -v commands and receive an error like command not found, it’s possible that Node.js wasn’t properly added to your system’s PATH during installation.

    Solution:

    • Reopen your Terminal and try running the commands again.
    • If it still doesn’t work, check if Node.js and NPM are installed in /usr/local/bin/. If not, reinstall Node.js and make sure the installation completes without errors.
  2. Permission Issues When Installing Packages Globally
    Sometimes, you might encounter permission errors when trying to install global packages with the -g flag (e.g., npm install -g nodemon).

    Solution:

    • Use the sudo command to grant administrator privileges:

      sudo npm install -g nodemon

      You’ll need to enter your admin password to allow the installation.
  3. NPM Install Failing
    If NPM is failing to install packages, it might be due to a network or proxy issue.

    Solution: You can try clearing the NPM cache by running:

    npm cache clean –force

    Then, try the installation again.

Method 2: Installing Node.js and NPM via Homebrew

Homebrew is a package manager for macOS that simplifies the process of installing software. It’s a popular option for developers because it allows you to easily install, update, and manage software packages, including Node.js and NPM.

Step 1: Install Homebrew (If You Don’t Already Have It)

If you don’t have Homebrew installed on your Mac, follow these steps to install it:

  1. Open Terminal
    Press Command + Space, type Terminal, and hit Enter to open the terminal.

  2. Run the Homebrew Installation Command
    Paste the following command into your terminal and press Enter:

    /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)”

    This will download and install Homebrew on your Mac. Follow the on-screen instructions to complete the installation. You may need to enter your admin password during the process.

  3. Verify Homebrew Installation
    After the installation, verify that Homebrew is installed by running:

    brew -v

    This will display the version of Homebrew installed on your system, confirming that it’s ready to use.

Step 2: Install Node.js and NPM with Homebrew

Once Homebrew is installed, you can use it to install Node.js and NPM in just a few simple steps.

  1. Install Node.js
    In the terminal, run the following command:

    brew install node

    Homebrew will automatically download and install both Node.js and NPM.

  2. Verify the Installation
    After the installation is complete, check the versions of Node.js and NPM by running the following commands:

    node -v

    and

    npm -v

    If both commands return version numbers, Node.js and NPM were successfully installed via Homebrew.

Step 3: Updating Node.js and NPM with Homebrew

One of the advantages of using Homebrew is that it makes updating software packages incredibly easy. Here’s how to update Node.js and NPM:

  1. Update Homebrew
    First, update Homebrew to make sure you’re installing the latest version of Node.js. Run this command in the terminal:

    brew update

  2. Upgrade Node.js
    To update Node.js and NPM to the latest versions, run:

    brew upgrade node

Troubleshooting Homebrew Installation Issues

Sometimes, Homebrew might run into issues, especially if there are conflicts with other packages or missing dependencies. Here are some troubleshooting tips:

  1. Homebrew Update Errors
    If Homebrew encounters errors during an update or installation, try running:

    brew doctor

  2. This command checks your system for potential issues and provides suggestions on how to fix them.

  3. Homebrew Fails to Install Node.js
    If Homebrew fails to install Node.js, it could be due to a network issue or a corrupted Homebrew setup. Try running:

    brew cleanup brew doctor


Then, attempt the installation again.

Wrapping Up

Installing Node.js and NPM on Windows and Mac is simpler than you might think, especially with step-by-step instructions like these. Now, you’re equipped with the power of Node.js to build dynamic applications and manage your project dependencies with NPM. Whether you’re on a Windows PC or a Mac, you’re ready to dive into the world of JavaScript development.

Don’t wait! Install Node.js today and take your coding skills to the next level. The world of modern web development is at your fingertips!

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur

Admin | Content Manager

Related Blogs

May 16, 2025 Admin

Laravel vs PHP: Dissecting The Backend Frameworks in Detail!

Read More

May 14, 2025 Admin

Laravel vs. Symfony: Comparison of Two PHP Frameworks

Read More

May 12, 2025 Admin

Comparing Nodejs vs Java: Your Backend Tech Stacks Explained

Read More

Our Offices

Let’s connect and build innovative software solutions to unlock new revenue-earning opportunities for your venture

India
USA
Canada
United Kingdom
Australia
New Zealand
Singapore
Netherlands
Germany
Dubai
Scroll to Top