10000 Cannot find module '/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js' · Issue #460 · modelcontextprotocol/typescript-sdk · GitHub
[go: up one dir, main page]

Skip to content
Cannot find module '/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js' #460
Open
@mattgodbolt

Description

@mattgodbolt

Describe the bug

In my typescript ESM module project (https://github.com/compiler-explorer/compiler-explorer) I tried to install and use this package, and it picks up @modelcontextprotocol/sdk@1.11.0. That package appears to come from git+ssh://git@github.com/modelcontextprotocol/typescript-sdk.git#621ccea...
This git package is missing the dist subdirectory.

To Reproduce

  1. Create a new project and install dependencies:
mkdir mcp-repro && cd mcp-repro
npm init -y
npm install @modelcontextprotocol/sdk@github:modelcontextprotocol/typescript-sdk tsx
  1. Create a simple TypeScript file (mcp-repro.ts):
// Simple file to test MCP SDK import
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
console.log('McpServer successfully imported:', McpServer);
  1. Run the file with tsx: npx tsx mcp-repro.ts

Expected behavior
The script should successfully import the McpServer class from the SDK and output its details.

Actual behavior

$ npx tsx mcp-repro.ts
node:internal/modules/cjs/loader:1281
  const err = new Error(`Cannot find module '${request}'`);
              ^

Error: Cannot find module '/tmp/mcp-repro/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js'
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:1281:15)
    at finalizeEsmResolution (node:internal/modules/cjs/loader:1269:15)
    at resolveExports (node:internal/modules/cjs/loader:638:14)
    at Function._findPath (node:internal/modules/cjs/loader:743:31)
    at node:internal/modules/cjs/loader:1230:27
    at nextResolveSimple (/tmp/mcp-repro/node_modules/tsx/dist/register-D2KMMyKp.cjs:3:942)
    at /tmp/mcp-repro/node_modules/tsx/dist/register-D2KMMyKp.cjs:2:2550
    at /tmp/mcp-repro/node_modules/tsx/dist/register-D2KMMyKp.cjs:2:1624
    at resolveTsPaths (/tmp/mcp-repro/node_modules/tsx/dist/register-D2KMMyKp.cjs:3:760)
    at /tmp/mcp-repro/node_modules/tsx/dist/register-D2KMMyKp.cjs:3:1038 {
  code: 'MODULE_NOT_FOUND',
  path: '/tmp/mcp-repro/node_modules/@modelcontextprotocol/sdk/package.json'
}

Node.js v22.13.1

Additional context

Related issues:

  1. Issue Error [ERR_PACKAGE_PATH_NOT_EXPORTED] when importing @modelcontextprotocol/sdk #427: Error [ERR_PACKAGE_PATH_NOT_EXPORTED] when importing @modelcontextprotocol/sdk #427
    - Nearly identical to our error - package can't find the specified paths
    - Problem with the exports field in package.json not correctly mapping to dist files
  2. Issue ERR_MODULE_NOT_FOUND When Importing from proxyProvider Without .js Extension #440: ERR_MODULE_NOT_FOUND When Importing from proxyProvider Without .js Extension #440
    - Similar module not found error
    - Workaround: add .js extension to imports (though this won't help in our case)
  3. Issue Module Resolution Error in ESM: Unable to Resolve @modelcontextprotocol/sdk/types.js #459: Module Resolution Error in ESM: Unable to Resolve @modelcontextprotocol/sdk/types.js #459
    - Another module resolution issue in ESM context
    - Very similar error pattern to what we're experiencing

The core issue appears to be in how the SDK is packaged and exported:

  1. The package.json has an exports field that points to:
    "exports": {
    "./": {
    "import": "./dist/esm/
    ",
    "require": "./dist/cjs/*"
    }
    }
  2. However, when installed, the dist directory is missing entirely, causing any imports
    to fail with ERR_MODULE_NOT_FOUND
  3. This is likely happening because the package is being installed directly from GitHub
    without being properly built first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0