
Getting started with Node.js & npm
In this codelab you'll install Node.js, learn how npm works, explore the public package registry, create your first project, and discover how AI coding agents use npm packages to build software faster.
What you'll use
- Node.js — A JavaScript runtime that lets you run JavaScript outside the browser — on your computer, on servers, and more. Learn more →
- npm — The default package manager for Node.js. It installs, updates, and manages libraries your projects depend on. Learn more →
- npm Registry — A public website with over 2 million open-source packages you can browse, search, and install. Learn more →
1What is Node.js?
JavaScript was originally designed to run only inside web browsers. Node.js changed that — it lets you run JavaScript anywhere: on your laptop, on a server, or inside tools like build systems and development servers.
Today, Node.js is essential for modern web development. Here's what it powers:
- •Running development servers locally (e.g. Next.js, Vite)
- •Building and bundling front-end applications
- •Running back-end APIs and server-side logic
- •Scripting, automation, and command-line tools
🔷 We'll actually be using TypeScript
Throughout this course, we'll write TypeScript rather than plain JavaScript. TypeScript is a superset of JavaScript — that means every line of JavaScript is already valid TypeScript. TypeScript simply adds optional type annotations that help catch mistakes before your code runs.
Under the hood, TypeScript compiles down to regular JavaScript, and Node.js runs that JavaScript. So everything you're learning about Node.js and npm applies exactly the same whether you write JavaScript or TypeScript.
Why TypeScript? It gives you better autocomplete, clearer error messages, and makes your code easier for both humans and AI agents to understand. Most modern projects — including the one you're building in this course — use TypeScript by default.
2Install Node.js
Node.js comes with npm pre-installed, so you only need to install one thing. We recommend downloading the LTS (Long Term Support) version for stability.
- Go to nodejs.org and click the LTS download button.
- Run the .msi installer — the default options work fine for most users.
- Open a new Command Prompt or PowerShell window when done.
Using Windows? See Pro Tip #1 to set up Git Bash as your default IDE terminal.
Verify both installed correctly:
node --versionnpm --versionYou should see version numbers for both node and npm.
3Understanding npm
npm (Node Package Manager) is how you add libraries to your projects. Instead of writing everything from scratch, you can install packages that other developers have built and shared.
Install a package into your project:
npm install lodashInstall a dev-only dependency (not shipped to production):
npm install --save-dev typescriptInstall a tool globally (available everywhere on your system):
npm install -g vercelWhen you install a package, npm adds it to a file called package.json, which tracks all the dependencies your project needs. Anyone who clones your project can run npm install to get the exact same packages.
Packages themselves are downloaded into a node_modules folder. You never need to edit this folder — npm manages it for you, and it's typically excluded from version control via .gitignore.
4Exploring the npm registry
The npmjs.com is the public website where all npm packages are listed. You can search for packages, read their documentation, and check their popularity.
When evaluating a package, look for these signals:
- •Weekly downloads — More downloads usually means it's widely trusted and actively used.
- •Version number — A version above 1.0 suggests it's considered stable by its maintainers.
- •Dependencies — Fewer dependencies means less risk of breaking changes.
- •README & docs — Good documentation is a sign of a well-maintained package.
Try searching from the command line:
npm search react5Your first project
Let's create a new project folder and initialize it with npm:
mkdir my-first-project && cd my-first-projectnpm init -yNow install your first package — let's use chalk, a popular library for adding color to terminal output:
npm install chalkNotice that your package.json now lists chalk as a dependency, and a node_modules folder has appeared.
📁 package.json This file is the heart of every Node.js project. It records your project's name, version, scripts, and dependencies. It's how npm and other tools understand your project.
6Using npm with AI coding agents
When you use an AI coding agent like Google Antigravity, GitHub Copilot, or Cursor, it can automatically install npm packages as needed. If the agent needs a library to accomplish a task, it will run npm install for you.
Here's what you should know about how agents use npm:
- •Agents prefer popular, well-maintained libraries over writing custom code from scratch — this means fewer bugs and better compatibility.
- •You can ask the agent to use a specific package, or let it choose the best one for the task.
- •All packages the agent installs are recorded in your package.json, so you always have visibility into what was added.
- •If the agent installs something you don't want, you can remove it with npm uninstall <package-name>.
⚡ Why existing libraries? Re-inventing the wheel is slow and error-prone. Popular npm packages have been tested by millions of users, receive regular security updates, and have extensive documentation. Using them lets you (and your AI agent) focus on what makes your project unique.
7Useful npm commands
Here's a quick reference of commands you'll use frequently:
| Command | What it does |
|---|---|
| npm install | Install all dependencies listed in package.json |
| npm run dev | Start the development server (if configured) |
| npm run build | Build the project for production |
| npm outdated | Check which packages have newer versions available |
| npm update | Update packages to their latest compatible versions |
| npm uninstall <pkg> | Remove a package from your project |
| npx <cmd> | Run a package command without installing it globally |
8What's next
Now that you have Node.js set up, here are some great next steps:
🔗 Build a backend API
Create REST APIs with Express — Build a backend API with Node.js
⚛️ Build a React app
Create a modern frontend with React and Vite — Build a React app with Vite
🐙 Set up GitHub
Track your code with Git and host it online — Getting started with GitHub
▲ Deploy your apps
Ship full-stack apps with automatic deployments — Deploy web apps with Vercel
📖 Lesson: See how all the pieces of a web app fit together in our Elements of a web application lesson.
You're all set!
You now have Node.js and npm installed, you know how to find and install packages, and you understand how AI agents leverage npm to help you build faster.
Back to codelabs