npm, Yarn, pnpm: Which Frontend Package Manager Should You Start With?
Lockfiles tell you which package manager a project actually uses, and mixing npm, Yarn, or pnpm on the same repo can silently diverge dependency resolution. Newcomers get a concrete path from Go conventions to npm commands, plus a simple rule to follow the existing lockfile instead of switching tools.
npm, Yarn, and pnpm all solve the same problem: installing and managing JavaScript dependencies and running project scripts. The guide maps each concept to Go equivalents (go get to npm install, go.mod to package.json, go.sum to package-lock.json), lowering the barrier for developers coming from the Go ecosystem. It then lays out the core differences in storage, lockfiles, and typical use cases, while explicitly recommending that newcomers master npm first because the three share the same core functionality.
package.json sits at the center of the workflow. The guide explains the roles of the scripts, dependencies, and devDependencies fields, and shows how commands like npm install and npm install -D fill them. A reference table covers everyday commands, including npm ci for clean, lockfile-exact installs suitable for CI/CD. The distinction between package.json, package-lock.json, and node_modules is made plain: the lockfile records exact versions and should be committed to Git, while node_modules is local and should not.
A final command comparison across npm, Yarn, and pnpm gives the exact syntax for install, add, remove, and run operations. The closing advice matters for real projects: when you inherit a codebase, detect its package manager from the lockfile (pnpm-lock.yaml, yarn.lock, or package-lock.json) and stick with it rather than mixing tools.
The Go-to-frontend mapping gives a developer who already knows go get, go.mod, and go.sum a nearly frictionless on-ramp to npm, which is why the guide is structured around it.
Recommending npm as the sole tool to learn first acknowledges that the three managers are functionally equivalent for typical projects, so parallel learning only adds cognitive load without practical payoff.
The lockfile-as-identifier heuristic is a practical way to avoid tool-switching damage; seeing pnpm-lock.yaml or yarn.lock is enough to know which manager a repo expects.