Skip to content

zod declared in both dependencies and peerDependencies causes ERR_MODULE_NOT_FOUND with pnpm strict isolation #4288

@GrzywN

Description

@GrzywN

Describe the bug
zod is declared in both dependencies and peerDependencies in package.json. With strict package managers (pnpm with enableGlobalVirtualStore or default strict isolation), the peer dependency declaration takes precedence — pnpm does not co-locate zod alongside the package in the virtual store. Packages that depend on @modelcontextprotocol/sdk but do not explicitly declare zod themselves (e.g. @modelcontextprotocol/server-sequential-thinking) fail at runtime with ERR_MODULE_NOT_FOUND when the SDK tries to import zod via ESM.

To Reproduce
Steps to reproduce the behavior:

  1. Create a project using pnpm with enableGlobalVirtualStore: true (or default strict mode)
  2. Install any package that depends on @modelcontextprotocol/sdk without declaring zod itself:
    pnpm add @modelcontextprotocol/server-sequential-thinking
  3. Run the package:
    pnpm exec mcp-server-sequential-thinking or pnpx -y @modelcontextprotocol/server-sequential-thinking@2025.12.18

Expected behavior
Package starts successfully. zod is a declared dependency of the SDK — it should be available at runtime without the consumer explicitly installing it.

Logs

❯ pnpm exec mcp-server-sequential-thinking
node:internal/modules/run_main:107
    triggerUncaughtException(
    ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'zod' imported from /home/user/.pnpm-store/v11/links/@modelcontextprotocol/server-sequential-thinking/2025.12.18/b16d7229fe63eba8f5c9df434194638ecedcbeff81abdf52f136fde8d100ab1e/node_modules/@modelcontextprotocol/server-sequential-thinking/dist/index.js
Did you mean to import "zod/index.cjs"?
    at Object.getPackageJSONURL (node:internal/modules/package_json_reader:301:9)
    at packageResolve (node:internal/modules/esm/resolve:768:81)
    at moduleResolve (node:internal/modules/esm/resolve:859:18)
    at defaultResolve (node:internal/modules/esm/resolve:992:11)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:691:20)
    at #resolveAndMaybeBlockOnLoaderThread (node:internal/modules/esm/loader:708:38)
    at ModuleLoader.resolveSync (node:internal/modules/esm/loader:740:52)
    at #resolve (node:internal/modules/esm/loader:673:17)
    at ModuleLoader.getOrCreateModuleJob (node:internal/modules/esm/loader:593:35)
    at ModuleJob.syncLink (node:internal/modules/esm/module_job:163:33) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v24.16.0

Additional context
Node version: v24.16.0
Pnpm version: 11.5.2 with enableGlobalVirtualStore: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions