How to Install Node.js and npm on Windows or macOS
Tags: javascript, node, tutorial, beginners
Published: 2021-01-18 10:48:53

*This post was originally published at [kais.blog](https://kais.blog/p/how-to-install-nodejs-and-npm-on-windows-or-macos).*

**Let's move your learning forward together!** [Follow me on Twitter](https://twitter.com/intent/follow?screen_name=kais_blog) for your daily dose of developer tips. Thanks for reading my content!

---

Installing Node.js and npm on Windows or macOS is an easy task. Learn how to do it within a few minutes.

## What are Node.js and npm?

**Node.js** is a JavaScript runtime that allows you to execute programs written in JavaScript. With Node.js JavaScript is not restricted to the browser anymore. In fact, by using Node.js you can [create web, mobile and desktop apps](https://dev.to/kais_blog/javascript-is-everywhere-5fo0). It's awesome! You should give it a try!

**npm** (originally short for *Node Package Manager*) is a command-line-utility that's included with your Node.js installation. It acts as a package manager for JavaScript. With npm you can download so-called packages from a package registry (most of the time - the [*npm registry*](https://www.npmjs.com/)). These packages are provided by other developers and help you develop your applications. You can also publish your own packages and thus, share your code and take part in the community.

## How to Install Node.js and npm

### Step 1: Download and Run the Node.js Installer

First, you have to download the installer. Navigate to:

https://nodejs.org/en/download/

**Click** the **Windows Installer** or **macOS Installer** button. This starts downloading the latest, recommended Node.js version for Windows / macOS. Once the installer has finished downloading, you are ready to run it. So, browse to the location where you have saved the file and **run the installer**.

The installer will guide you through the steps. You can leave it with the defaults. When the installer has finished the installation, you are ready to use Node.js. Let's verify that everything works as intended in the next step.

### Step 2: Verify Your Node.js Installation

After running the installer for Node.js, you should have access to the `node` and the `npm` command-line-utilities. Let's try it! Open the **Windows Command Prompt** / **Windows PowerShell** or **Terminal** (macOS). Enter the following:

```bash
node -v
```

Now, you should see the current Node.js version installed on your system. Let's try the same for npm:

```bash
npm -v
```

This should show you the current npm version on your system. If everything works, you are ready to create your first simple Node.js program. If you see an error, try restarting your computer. Then, try again.

### Step 3: Create Your First Node.js Program

Now that you have successfully installed Node.js and npm on your computer, you are ready to create your first Node.js program. Launch a text editor of your choice. Write the following line of **JavaScript** into a new file:

```js
console.log("Hello, world!");
```

Now, save that file and name it `hello.js`. Open your **Windows Command Prompt / PowerShell** or **Terminal** (macOS). Use it to navigate to the place where you've saved the file. Then, type in the following:

```bash
node hello.js
```

You should see `Hello, world!`. Nice! You've successfully created your first Node.js program. As you can see, you've executed JavaScript on your computer. Well, there's far too much to show you now. Just let me tell you something - learning Node.js is a valuable skill. You can create [web, mobile and desktop apps with it. Even games!](https://dev.to/kais_blog/javascript-is-everywhere-5fo0)

Have fun learning! See you around!

---

**Let's move your learning forward together!** [Follow me on Twitter](https://twitter.com/intent/follow?screen_name=kais_blog) for your daily dose of developer tips. Thanks for reading my content!

*This post was originally published at [kais.blog](https://kais.blog/p/how-to-install-nodejs-and-npm-on-windows-or-macos).*