73 73. Step 0: Install Node.js and npm
As of Oct 22, 2026 · Official docs: Node.js · npm
In this project we will be using Node.js and the npm tool. Below we will explain what they are and how they are used. For now though, let’s first make sure that you have the necessary software installed.
First - understand that you only need to install Node.js.
npmis automatically installed when you install Node.js.To see if
npmis already installed (and hence Node.js), type the following command at the Terminal prompt:npm -vIf npm is already installed you should see the npm version number. If you do, you can skip to the explanations of what Node.js and npm are.
If you didn’t see npm’s version number, then npm (and Node.js) is most probably not installed.
You can install
Node.jsfrom here - https://nodejs.org/en/download. Once you’ve installed Node.js you should have the npm tool also.After you’ve installed Node.js, close your original Terminal and open a new Terminal window. Then run
npm -v. You should see the version number for npm. If that worked, great. Otherwise, try to figure out how to use npm with the help of your favorite AI (or a knowledgeable human).
73.1 What is Node.js?
Node.js is a JavaScript runtime environment. In other words, it is a program that runs JavaScript code.
JavaScript was originally created to run inside web browsers to make webpages more interactive - e.g. dropdown menus, popup menus, tell users that they didn’t fill out a form properly, etc. It is still used inside browsers in these ways and others. To run JavaScript in a browser, you do NOT need Node.js.
Node.js is used to run JavaScript code outside of a browser. In this way you can use JavaScript to create any type of program. This made JavaScript more similar to other languages such as Python, Java, R, etc. Node.js was the first widely used way to run JavaScript outside the browser, on servers and on your own computer. Today there are other JavaScript runtimes, such as Bun and Deno. However, Node.js is still very popular.
73.2 What are Packages?
When developers build software, they often need to solve common problems: connecting to databases, handling dates and times, processing images, and so on. Rather than writing this code from scratch every time, developers create reusable bundles of code called packages (sometimes also called libraries).
If you’ve used R or Python, you’re already familiar with this concept: - In R, you might use packages like ggplot2 for visualization or dplyr for data manipulation - In Python, you might use pandas for data analysis or requests for making HTTP requests
JavaScript packages work the same way. For example, instead of writing complex code to handle dates, you could use a package like date-fns that someone else has already written and tested.
73.3 What is a Package Manager?
A package manager is a tool that helps you install, update, and manage packages. When you use R, you might run install.packages("ggplot2"). In Python, you use pip install pandas. These commands use package managers to:
- Download the package from a central repository
- Install it in the right location on your computer
- Keep track of which packages your project uses
- Manage dependencies (packages that other packages need to work)
73.4 What is npm (Node Package Manager)?
npm stands for “Node Package Manager”. It is a package manager that comes with Node.js. When you install Node.js, npm comes with it automatically.
Later we will cover more about how to use npm. For now though we just want you to understand what it is. npm connects to a massive online repository of JavaScript packages, called the npm registry. When you need a package, you simply run the following command from the CLI (e.g. Bash) to have npm download the package and make it available for your project to use.
npm install package-nameThe npm registry is one of the largest package ecosystems in the world, with millions of packages available. This means that for almost any problem you’re trying to solve, someone has probably already created a package to help.
73.5 OK, so how do I use npm?
We’ll cover this a little later, in Step 2: Installing the Node.js packages with npm.
Practice Questions
Easy
Question 1 · Multiple choice
What is Node.js?
- A web browser
- A JavaScript runtime environment: a program that runs JavaScript code outside a browser
- A package of reusable JavaScript code
- A database
Question 2 · True or false
After you install Node.js, you have to install npm separately.
Question 3 · Write the command
Write the command that checks whether npm (and therefore Node.js) is installed on your computer.
Question 4 · Short answer
What does “npm” stand for, and what is it used for?
Medium
Question 5 · Matching
Match each language with a command that installs a package for it.
| Language | Command | |
|---|---|---|
| 1. R | A. pip install pandas |
|
| 2. Python | B. npm install date-fns |
|
| 3. JavaScript (Node.js) | C. install.packages("ggplot2") |
Question 6 · Short answer
A package manager does four jobs. List them.
Question 7 · Multiple choice
Which of these does not need Node.js?
- Making a drop-down menu work on a web page in your browser
- Running
npm installto download packages - Running a JavaScript program from the terminal, outside the browser
- Using JavaScript to build a program that isn’t a web page, the way you might use Python or R
Question 8 · Short answer
Why do developers use packages instead of writing all of their code themselves? Give an example from the page.
Question 9 · True or false
Node.js is the only JavaScript runtime environment.
Hard
Question 10 · Scenario
Sam installs Node.js on his Windows laptop. In the Git Bash window he had opened before the installation, he types npm -v and gets an error saying the command was not found. What should he try, and why might it help?
Question 11 · Scenario
Package A needs package B in order to work. You run npm install A. What will npm do about package B, and why is that helpful?
Question 12 · Long answer
Explain how Node.js, npm and a package (such as date-fns) relate to each other. Use an analogy with R or Python.