The short version
Almost no software is written entirely from scratch. Developers use packages (also called libraries or modules), pre-built pieces of code that handle common tasks. Need to parse dates? There's a package for that. Need to talk to an API? There's a package for that. npm is the system that manages these packages for JavaScript and TypeScript projects.
When you see npm install in a tutorial, it's downloading the packages that project depends on. When you see a package.json file, that's the project's list of dependencies.
How it works
npm has three parts:
- The registry is a public database of over 2 million packages. Anyone can publish a package. Anyone can install one. It's at npmjs.com.
- The CLI tool is what you run in your terminal.
npm install,npm run dev,npm build. It readspackage.json, downloads packages from the registry, and manages thenode_modulesfolder where they're stored. - package.json is the project's manifest. It lists the project's dependencies, scripts (commands you can run), and metadata.
A typical package.json:
{
"name": "my-project",
"dependencies": {
"next": "16.1.7",
"react": "19.2.3"
},
"devDependencies": {
"typescript": "^5"
},
"scripts": {
"dev": "next dev",
"build": "next build"
}
}
dependencies are packages the app needs to run. devDependencies are only needed during development (like TypeScript or testing tools). The caret (^5) means "any version 5.x".
npm install reads this file and downloads everything listed into a node_modules folder. This folder is often enormous (hundreds of megabytes) and is never committed to Git. Instead, package-lock.json records the exact versions installed so other developers get identical dependencies.
Alternatives to npm: yarn and pnpm do the same job with different performance characteristics. They all use the same registry and the same package.json format.
Why it matters
If you work with any JavaScript or TypeScript project, npm is how you install tools, start dev servers, and build for production. Understanding package.json, npm install, and npm run covers most of what you need day to day. When a tutorial says "run npm install," you'll know what's actually happening.