Skip to main content
This covers dependency-related problems that occur in pnpm workspace environments and how to resolve them.

Strict Dependency Resolution

Symptoms

Cause

pnpm has stricter dependency resolution than Yarn or npm. It doesn’t automatically install missing peer dependencies and requires explicit installation.

Solutions

1. Explicitly Install Peer Dependency

.npmrc:
Drawback: Dependency tree can become unpredictable

3. Use pnpm.overrides

package.json:

Workspace Protocol Error

Symptoms

Cause

Used workspace:* protocol but that package doesn’t exist in the workspace.

Solutions

1. Check Workspace Packages

pnpm-workspace.yaml:

2. Check Package Name

3. Fix package.json

Catalog Version Mismatch

Symptoms

Cause

Version defined in pnpm-workspace.yaml catalog differs from package.json version.

Solutions

package.json:

2. Update Catalog

pnpm-workspace.yaml:

3. Unify All Workspace to Catalog Version

Hoisting Issues

Symptoms

Module is installed but cannot be found.

Cause

pnpm doesn’t hoist dependencies by default. Each package is isolated under node_modules/.pnpm.

Solutions

1. Use public-hoist-pattern

.npmrc:
Hoists specific packages to root node_modules.

2. shamefully-hoist (Last Resort)

.npmrc:
Warning: Works like npm/yarn but gives up pnpm’s advantages.

3. Declare Correct Dependencies

Declaring required packages directly is safest.

TypeScript Path Mapping Error

Symptoms

Cause

TypeScript path mapping doesn’t work properly due to pnpm’s strict dependency resolution.

Solutions

1. tsconfig.json Configuration

2. tsx/ts-node Configuration

tsconfig.json:
Install:

Phantom Dependencies

Symptoms

A package imported directly in code doesn’t exist in package.json but works.
Works locally but fails in CI or other environments.

Cause

Phantom Dependencies - accidentally accessible through dependencies of other packages.

Solutions

1. Add Explicit Dependency

2. Run pnpm check

onlyBuiltDependencies Error

Symptoms

Cause

Packages in onlyBuiltDependencies list are configured to install optionally only.

Solution

pnpm-workspace.yaml:
These packages contain binaries and require platform-specific installation. If installation fails:

Overrides Not Applied

Symptoms

pnpm.overrides is configured but not applied.

Causes

  1. Overrides syntax is wrong
  2. Set in non-workspace-root location
  3. pnpm version is old

Solutions

1. Correct Overrides Syntax

package.json (workspace root):

2. Use in pnpm-workspace.yaml

3. Verify Applied

Circular Workspace Dependencies

Symptoms

Cause

Workspace packages reference each other, causing circular dependency.

Solutions

1. Redesign Dependency Structure

Solution:

2. Use peerDependencies

Cache Issues

Symptoms

Previous version is still used even after updating dependencies.

Solutions

1. Clean pnpm store

2. Complete Reinstall