Claude Code Monorepo Workspace (2026)

The Error

ERR_PNPM_WORKSPACE_PKG_NOT_FOUND: Package "@myorg/shared" not found
  in any of the workspace packages.
# Or with npm workspaces:
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@myorg%2fshared
  (Package is local but npm tried to fetch from registry)
# Or:
Error: Cannot find module '@myorg/shared' or its corresponding type declarations.
  at resolveModuleName (typescript/lib/typescript.js:42567:35)

The Fix

  1. Verify workspace configuration matches your package manager
# For pnpm — check pnpm-workspace.yaml exists
cat pnpm-workspace.yaml
# Should contain:
# packages:
#   - 'packages/*'
#   - 'apps/*'
# For npm — check package.json workspaces
cat package.json | python3 -c "import sys,json; print(json.load(sys.stdin).get('workspaces', 'NOT SET'))"
  1. Use the workspace protocol for local dependencies
# In packages/app/package.json, reference local packages with workspace:
# For pnpm:
# "dependencies": { "@myorg/shared": "workspace:*" }
# For npm:
# "dependencies": { "@myorg/shared": "*" }
# Then install to create proper symlinks:
pnpm install  # or npm install
  1. Verify the fix:
# Check that the workspace package is linked correctly
ls -la node_modules/@myorg/shared
# Expected: Symlink pointing to ../../packages/shared
# Verify TypeScript can resolve it
npx tsc --noEmit --traceResolution 2>&1 | grep "@myorg/shared" | head -5
# Expected: Resolution path showing local package, not registry

Why This Happens

Monorepo workspace resolution depends on three things aligning: the workspace root configuration (pnpm-workspace.yaml or package.json workspaces), the dependency declaration in consuming packages (using workspace:* protocol for pnpm), and the actual symlinks in node_modules. When Claude Code adds a new package dependency or creates a new workspace package, it often misses the workspace protocol prefix, causing the package manager to search the npm registry instead of linking locally. TypeScript resolution fails separately because it needs paths or references in tsconfig.json.

If That Doesn’t Work

  • Alternative 1: Add TypeScript project references: "references": [{"path": "../shared"}] in tsconfig.json
  • Alternative 2: Add path aliases in tsconfig.json: "paths": {"@myorg/shared": ["../shared/src"]}
  • Check: Run pnpm ls --depth 0 or npm ls to see which packages are resolved and whether they point to local or registry versions

Prevention

Add to your CLAUDE.md:

This is a pnpm monorepo. Always use workspace:* protocol for local package dependencies. After adding a new workspace package, run pnpm install. Include the package in pnpm-workspace.yaml before referencing it. Check tsconfig.json paths for TypeScript resolution.

Related articles: Monorepo Setup Guide, Claude Code Not Working After Update, Troubleshooting Hub

See Also

Frequently Asked Questions

Does this error affect all operating systems?

This error can occur on macOS, Linux, and Windows (WSL). The exact error message may differ slightly between platforms, but the root cause and fix are the same. macOS users may see additional Gatekeeper or notarization prompts. Linux users should check that the relevant system packages are installed. Windows users should ensure they are running inside WSL2, not native Windows.

Will this error come back after updating Claude Code?

Updates can occasionally reintroduce this error if the update changes default configurations or dependency requirements. After updating Claude Code, verify your project still builds and runs correctly. If the error returns, reapply the fix and check the changelog for breaking changes.

Can this error cause data loss?

No, this error occurs before or during an operation and does not corrupt existing files. Claude Code’s edit operations are atomic — they either complete fully or not at all. However, if the error occurs during a multi-step operation, you may have partial changes that need to be reviewed with git diff before continuing.

How do I report this error to Anthropic if the fix does not work?

Open an issue at github.com/anthropics/claude-code with: (1) the full error message including stack trace, (2) your Node.js version (node --version), (3) your Claude Code version (claude --version), (4) your operating system and version, and (5) the command or operation that triggered the error.

This fix also applies if you see variations of this error:

  • Connection or process errors with similar root causes in the same subsystem
  • Timeout variants where the operation starts but does not complete
  • Permission variants where access is denied to the same resource
  • Configuration variants where the same setting is missing or malformed

If your specific error message differs slightly from the one shown above, the fix is likely the same. The key indicator is the operation that failed (shown in the stack trace) rather than the exact wording of the message.

Try it: Paste your error into our Error Diagnostic for an instant fix.