Skip to content

ERR_PACKAGE_PATH_NOT_EXPORTED with @modelcontextprotocol/express #1858

Closed

Description

@maximemoreillon

Describe the bug

I am getting a ERR_PACKAGE_PATH_NOT_EXPORTED with message No "exports" main defined in C:\Users\myusersmyproject\node_modules\@modelcontextprotocol\express\package.json when running the @modelcontextprotocol/express example as per the usage guide here

import { createMcpExpressApp } from '@modelcontextprotocol/express';
const app = createMcpExpressApp();

This looks similar to #726 , #427

To Reproduce

Node version 24.14.1 LTS on Windows 11.

Project initialized with

npm i -D typescript
npx tsc --init

verbatimModuleSyntax commented out in tsconfig

Expected behavior

Having no error

Additional context

Dependencies:

{
  // ...
  "dependencies": {
    "@modelcontextprotocol/express": "^2.0.0-alpha.2",
    "@modelcontextprotocol/node": "^2.0.0-alpha.2",
    "@modelcontextprotocol/server": "^2.0.0-alpha.2",
    "express": "^5.2.1"
  },
  "devDependencies": {
    "@types/express": "^5.0.6",
    "typescript": "^6.0.2"
  }
}

Activity

  1. added a commit that references this issue on Apr 16, 2026
    e683ec1
  2. ghost added
    ready for workEnough information for someone to start working on
    on Apr 16, 2026
  3. ghost added
    P2Moderate issues affecting some users, edge cases, potentially valuable feature
    on Apr 16, 2026
  4. maximemoreillon commented on Apr 17, 2026

    @maximemoreillon
    Author

    I have set "type": "module" in package.json and "module": "NodeNext", "moduleResolution": "NodeNext" but now I am getting:

    Error: Cannot find package '@cfworker/json-schema' imported from /home/moreillon/dev/mcp-sdk-test/node_modules/@modelcontextprotocol/server/dist/src-IKPjmxu7.mjs
    code: 'ERR_MODULE_NOT_FOUND'
    
  5. ghost added
    potentially closeBot recommends closing — needs maintainer review
    on Apr 17, 2026
  6. yasaichi commented on May 8, 2026

    @yasaichi

    I’m seeing what looks like another published artifact issue in the 2.0.0-alpha.2 packages, this time with Deno/JSR resolution.

    Minimal repro:

    // repro.ts
    import "npm:@modelcontextprotocol/server@2.0.0-alpha.2";
    deno run --reload --node-modules-dir=none repro.ts

    This fails with:

    error: Could not find package '@cfworker/json-schema'
    from referrer .../@modelcontextprotocol/server/2.0.0-alpha.2/dist/src-IKPjmxu7.mjs
    (@modelcontextprotocol/server@2.0.0-alpha.2).

    I checked the published tarball, and dist/src-IKPjmxu7.mjs contains a top-level static import:

    import { Validator } from "@cfworker/json-schema";

    But @cfworker/json-schema is published as an optional peer dependency, not a regular dependency, so Deno does not include it in the resolved npm dependency graph.

    From current main, this looks like it may already be fixed because the CF worker validator no longer appears to be pulled into the main server bundle. If that is correct, could you please publish a new alpha with the current packaging fixes? 2.0.0-alpha.2 is currently not usable from Deno/JSR even for a plain server import.

  7. mattzcarey commented on Sep 11, 2026

    @mattzcarey
    Member

    Closed as already fixed in PR #2405, published in 2.0.0: every v2 package now ships dual ESM and CommonJS builds with a require condition in its export map. See the express package.json and tsdown config. Verified against the published @modelcontextprotocol/express@2.0.0: require('@modelcontextprotocol/express') resolves createMcpExpressApp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Moderate issues affecting some users, edge cases, potentially valuable featurebugSomething isn't workingpotentially closeBot recommends closing — needs maintainer reviewready for workEnough information for someone to start working on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions