Skip to content
EduVerse
npm

npm

In depth

Tool

Also known as: Node Package Manager

The default package manager for Node.js. Manages dependencies and scripts through package.json.

npm, explained

Written by EduVerse

What it is

npm is the package manager that comes with Node.js. It installs JavaScript libraries (packages) from the public npm registry into a node_modules folder and keeps track of them in package.json. That same file holds scripts: short named commands such as dev or build, which you start with npm run dev or npm run build.

Why teams use it

Hardly any JavaScript project starts from scratch: you build on frameworks and libraries written by others. npm downloads them along with their own dependencies and records the exact versions in package-lock.json, so everyone on the team installs the same thing. Yarn and pnpm are alternatives, but npm is already there the moment you install Node.

An example from work

You clone a project, run npm install, and it stops with “ERESOLVE unable to resolve dependency tree”. Two packages want different versions of the same peer dependency. The quick escape is npm install --legacy-peer-deps, but the real fix is usually updating one of the packages so their requirements match again.

Our own explanation, not a quote from the book.

In the book

Sentences from The Software Realm, Decoded that mention npm, exactly as printed.

    4 more passages about npm in the full book

    Read every conversation where npm comes up, with the interactive slides and demos.

    See the book

    Where it fits

    Installing and managing JavaScript packages

    Coverage in the book

    In depth

    Covered in depth: multiple pages with explanations, examples and simulations.

    Appears in