Chase AdamsChase Adams
AboutContentPromptsPrototypesNewsletter

Why Claude Code Defaults to pnpm

Why Claude Code chooses pnpm as its default package manager - performance, disk efficiency, strict dependency resolution, and how to override it

2 minute read

Why Claude Code Defaults to pnpm

When you start using Claude Code for the first time for a Typescript/JavaScript project, you might notice it reaches for pnpm commands even though you never told it which package manager to use.

I was curious why and it turns out it's a deliberate design choice that reflects modern JavaScript tooling trends.

The Auto-Approval System

Claude Code has a whitelist of commands it can run without asking permission. Among these is Bash(npm:*) - a pattern that matches common package manager operations including npm, pnpm, yarn, and bun.

When no package manager is specified and no lock files exist to indicate preference, Claude Code defaults to pnpm for several reasons.

Why pnpm?

Performance

pnpm is significantly faster than npm for most operations. It installs packages in parallel and uses a content-addressable store, meaning packages are stored once globally and linked into projects rather than copied.

Disk Efficiency

Traditional npm creates a copy of every package in every project's node_modules. If you have 10 projects using React, you have 10 copies of React on disk.

pnpm uses symlinks to a global store. Those 10 projects share one copy of React, dramatically reducing disk usage - especially important for developers working on many projects.

Strict Dependency Resolution

pnpm creates a non-flat node_modules structure that prevents packages from accessing dependencies they didn't explicitly declare. This catches bugs that npm and yarn might miss, where code accidentally works because it's using a transitive dependency.

Modern Tooling Standard

pnpm has become increasingly common in modern JavaScript projects, especially in monorepos and performance-critical applications. It's the default for many new frameworks and build tools.

How Claude Code Actually Chooses

While pnpm is the fallback default, Claude Code should ideally detect your project's package manager by looking for:

  • pnpm-lock.yaml → pnpm
  • package-lock.json → npm
  • yarn.lock → yarn
  • bun.lockb → bun

If your project has a lock file, Claude Code will use the corresponding package manager.

Overriding the Default

You can control which package manager Claude Code uses:

  1. Explicit instruction - Just tell Claude to use npm/yarn/bun
  2. Lock files - Maintain the appropriate lock file in your project
  3. CLAUDE.md - Add package manager preferences to your project instructions

The default exists to make the common case fast and efficient, but it's always configurable when you need something different.

First Cohort
No Coding Experience Required

Build Your Website with AI—No Code Required

Learn to create and deploy professional websites using ChatGPT and Claude. Go from complete beginner to confident website builder.

Start Building Today

Post Details

Published
Oct 17, 2025
Share
ChatGPT

Latest Posts

Local AI Coding Tools

Local AI Coding Tools

AboutAI Workflow SpecContentStacksNewsletterPromptsRSS