npm started as Node's package manager and has quietly become the front-end build tool most teams reach for, even on projects with no server-side Node code at all - because it's a convenient way to install and script tools like Sass compilers and bundlers.

package.json is the source of truth

{
  "name": "client-site",
  "scripts": {
    "build:css": "node-sass scss/style.scss css/style.css",
    "watch:css": "node-sass -w scss/style.scss css/style.css"
  },
  "devDependencies": { "node-sass": "^3.10.0" }
}

Running npm install reads that file and pulls exactly those versions into node_modules - which should always be gitignored, since it's rebuildable from package.json on any machine.

Scripts replace ad hoc shell commands

npm run build:css is shorter to remember and, more importantly, shared automatically with anyone who clones the repo - no onboarding doc explaining which flags to pass a compiler by hand.

package.json is a contract, not just a file

{
  "dependencies": { "express": "^4.18.0" },
  "devDependencies": { "jest": "^29.0.0" }
}

The caret in ^4.18.0 allows minor and patch updates but not major ones - a small detail that matters enormously once a project has fifty dependencies each making their own version decisions. The package-lock.json file that npm generates alongside it pins the exact resolved versions, which is what actually makes "works on my machine" reproducible across a team.

The dependency tree is bigger than it looks

Installing one package can pull in dozens of transitive dependencies you never explicitly chose, each with its own maintenance status and security posture. Running npm audit periodically, and being genuinely selective about adding a dependency for something a few lines of code could handle directly, keeps that tree from becoming an unmanageable liability a year into a project.