How to install Node.js and NPM on Windows and macOS

Given the demand for full-stack development, Javascript is a solid technology for building full-fledged business applications.

Many JavaScript developers around the world struggle with replacing different frameworks and languages ​​to extend their code. This is where Node.js comes into play.

With Node.js, you can quickly build web applications with two-way connections where the client and server sides can communicate and exchange data in real time.

If you'd like to install Node and NPM on Windows and macOS systems, we're here to help. In this article, we will provide a step by step guide to install the software.

But first, let's go over the basics!

What is Node.js?

Node.js, also called Node, is an open source cross-platform runtime for executing JavaScript code outside of the browser. We often use Node.js to create back-end services, also called Application Programming Interfaces (APIs).

These services enable our client applications, such as a web application running in a browser or a mobile application running on a mobile device.

Applications are what the user sees and interacts with. However, these applications need to communicate with back-end services in the cloud or on a server to store data, send emails, run workflows, and more.

Node.js is ideal for building highly scalable, data-intensive, real-time back-end services that power our client applications.

While there are other tools and frameworks for creating server-side services, such as Ruby on Rails, Django, Flask, and Firebase, Node.js is different.

Node.js is easy to get started and can be used for prototyping and agile development. In addition, it can create incredibly fast and highly scalable services. It is even used by corporate organizations like PayPal, Uber, Netflix, Walmart, etc. due to its speed and scalability.

PayPal rebuilt one of their Java and Spring based applications with Node.js and found that:

  • Their apps were built in half the time with fewer people.
  • They used 33% fewer lines of code and 40% fewer files.
  • It also doubled the number of requests served per second, while reducing the average response time by 35%.

Node applications use Javascript everywhere, including Windows, macOS, and Linux. If you are a front-end developer with knowledge of JavaScript, you can easily transition to a full-time developer position, which will allow you to get a better job without learning a new programming language.

Because you can use Javascript on the frontend and backend, your source code will be cleaner and more consistent. As a result, you will use the same naming conventions, the same best practices, and the same tools.

In addition, Node offers you the largest ecosystem of open source libraries. This means that you can find any functions or building blocks to add to your application. This way you don't have to create these building blocks from scratch, but instead focus on the core of your application.

Now that you're familiar with the basics of Node.js, let's walk through the process you need to follow when installing Node for Windows or macOS.

Installing Node.js for Windows

Here are the steps to download Node.js for Windows:

Step 1: Go to the Node.js website and find the download page.

Step 2: Click on the Windows installer to download and open the file.

Step 3: Accept their license agreement by clicking next.

Step 4: Choose where you want to install Node.js, then click next.

Step 5 − If you are a beginner, stick with the default Node.js setup by clicking next. You can change this setting to suit your needs if you know the impact it will have on your application.

Step 6: Click Next again on the Custom Modules Tool page, then click Install.

Step 7: You have completed the installation. Now open the command console and start using Node.js.

Installing Node.js for macOS

Downloading Node.js for macOS is relatively easy. Complete the following installation steps:

Step 1: Go to your Node.js site. Click on the version of your choice.

Step 2: Download the file and open it in Finder.

Step 3: Specify the installation location and click Continue.

Step 4: Complete all installation steps by clicking "Continue" and agreeing to their terms until you reach the "Summary" section and receive installation confirmation.

Step 5: Congratulations, you have installed Node.js for macOS. Now open a terminal and start experimenting with commands.

Installing Node.js for Linux

Follow the steps below to install Node.js for Linux.

Step 1: Start by opening a terminal or pressing Ctrl + Alt + T.

Step 2: Enter:

sudo apt install nodejs

And then press enter.

However, running this command will not install the latest version of node.js.

Step 3: Go to the Node.js.org website and click Downloads.

Step 4: Scroll down and click "Install Node.js via Package Manager".

Step 5: Click "Debian and Ubuntu based Linux distributions".

Step 6: Once redirected, click on the Binary Node.js distributions link.

Step 7: A window will open and you will be redirected to the GitHub repository.

Step 8: Scroll down and find instructions for installing the latest version of Node.js. In this case, we will be installing Node.js v18.x.

Step 9: Copy and paste the first line from the instruction into your terminal and press Enter.

Step 10: You will see a message that the curl command was not found.

Step 11: Type sudo apt install curl to install curl. You will then be prompted to enter your Ubuntu password and press Enter.

Step 12 You have now installed curl on your operating system and can download the latest version of Node.js.

Copy and paste the second line from the Github installation instructions into your terminal and press Enter.

And you did!

How to Check NPM Version and Check Boot

NPM is the package manager for Node, which means it manages the dependencies for its packages.

Without NPM, you will need to unpack Node.js packages manually when you want to download the framework. Luckily, NPM automates this process and relieves you of the responsibility.

Updating NPM regularly improves code and updates your local packages used in your projects.

However, sometimes it misses the latest version of NPM. Therefore, you need to check the NPM version and update it manually.

While the process for checking and updating the NPM version is similar, there are a few differences between Windows and macOS.

Here is how to check Node.js version and check boot for Windows:

Type the command: node -v then press Enter and you will see the version number.

If you're on macOS, follow these steps to verify that Node.js and NPM are loaded.

Step 1: Open a macOS command terminal.

Step 2: Type node –version (that's the double dash before version) and press Enter. You will immediately see if you have the latest version installed.

To check the NPM version, type npm --version and press Enter.

Double check that the installed version matches the latest version listed on the Node.js website.

Once you've made sure your Node.js and NPM are properly installed on Windows or macOS, you're ready to start building new apps.

Summarizing

Node.js is a very popular programming environment, especially because of its practicality in front-end and back-end. Many developers choose Node.js for its simplicity and ability to develop complex applications. Plus, it can help you quickly become a full-fledged developer.

After following the steps above to install NPM and Node, you're ready to create back-end services. Installing them is the first step in your app development journey.

Related posts