npm vs pnpm: ?

npm, pnpm and

Comparisons

npmpnpm
and more(npm 7+ ) ( + )
node_modules +, 50%+
node_modules () ( )
Monorepo workspaces() workspaces(, )
100%
(Node.js ) ( command)
Lock package-lock.json pnpm-lock.yaml

npm

  • New,
  • ,
  • npm

pnpm

  • Monorepo ()
  • CI/CD
  • ()
  • ()

Examples

mergeExample

# npm npm init -y
npm install express
npm install -D jest
npm run test
npm ci # CI

rebaseExample

# pnpm pnpm init
pnpm add express
pnpm add -D jest
pnpm test
pnpm install --frozen-lockfile # CI

Common Errors

package-lock.json pnpm( lock )
pnpm and npm ( command)
CI npm install npm ci(ci )

and npm,. monorepo, pnpm.,.