How to Install Packages With npm (Beginner’s Guide)
You just set up your first Node.js project, and now you need real tools to build something useful. Here’s the good news: you won’t write those tools yourself. You’ll borrow them.
To install packages with npm, run npm install followed by the package name (for example, npm install express). One command downloads ready-made code into your project’s node_modules folder, and you can use it right away.
What does “install a package” actually mean?
A package is a chunk of code that someone else already wrote, tested, and shared. Think of it like borrowing a tool from a friend instead of building one from scratch.
When you install a package with npm, you pick the tool you need, npm fetches it from a giant online library, and it lands inside your project. No need to build it yourself. Just install it and use it.
If “npm” is new to you, start with our quick lesson on what npm is in the free Zero to AI Hero course, then come back here.
How do I install packages with npm?
Open your terminal inside your project folder and type one command:
npm install express
Press enter and watch it download. Let’s read the command word by word so it never feels mysterious:
npm install— the instruction to add a package.express— the name of the tool you want.- The code downloads into a folder called
node_modules. - It’s now instantly usable inside your own code.
That’s the whole flow: npm install fetches it, express is the tool, and node_modules is where it lands.
Why install instead of building it myself?
Because you get to stand on other people’s work. Writing a web server from scratch is genuinely hard. A package like express does that heavy lifting for you, so you can focus on your idea.
The code inside popular packages is proven and used by millions of developers. That means you ship in days, not months. It saves time, and you’re trusting code that already works.
This is how every professional builds. Indian startups rely on packages every single day — nobody rebuilds what already works well.
What is the node_modules folder?
node_modules is the folder where npm stores every package you install. You don’t edit it by hand — you just let npm fill it.
It can grow large fast, because each package may pull in smaller packages it depends on. That’s normal. In the next lesson you’ll learn how to keep this folder out of your saved code using .gitignore, so it doesn’t clutter your project.
Try it right now
Inside the project you set up earlier, type:
npm install express
Press enter. You’ll see npm download the package, and then express is ready to use in your code. That’s it — you just borrowed a powerful tool with one line.
Want to follow every step in order, from your first command to your first app? Work through the free Zero to AI Hero course, where we go from absolute zero to building real things with AI.
Key takeaways
- To install packages with npm, run
npm install <package-name>, likenpm install express. - A package is ready-made code someone else wrote and shared, so you don’t build it yourself.
- Installed packages land in the
node_modulesfolder and are instantly usable. - Installing saves time because you stand on proven code used by millions.
- Next up:
.gitignore— deciding what your project should and shouldn’t track.
🚀 Take the full free course: Zero to AI Hero — learn to build with AI from scratch. New lessons daily, in Hindi & English.
Want to actually learn this?
151 free 2-minute lessons — from "what's a file?" to building with AI.
▶ Start the free course