Skip to content

Error [ERR_PACKAGE_PATH_NOT_EXPORTED] when importing @modelcontextprotocol/sdk #427

Open
@LofiSu

Description

@LofiSu

Title: Error [ERR_PACKAGE_PATH_NOT_EXPORTED] when importing @modelcontextprotocol/sdk

Body:

Description:

I am encountering the following error when trying to start my NestJS application using the @modelcontextprotocol/sdk package:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in E:\nestMcp\in-browser-mcp-backend\node_modules\@modelcontextprotocol\sdk\package.json
    at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
    at new NodeError (node:internal/errors:405:5)
    at exportsNotFound (node:internal/modules/esm/resolve:366:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:713:9)
    at resolveExports (node:internal/modules/cjs/loader:590:36)
    at Module._findPath (node:internal/modules/cjs/loader:664:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1126:27)
    at Module._load (node:internal/modules/cjs/loader:981:27)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (E:\nestMcp\in-browser-mcp-backend\src\mcp\mcp.provider.ts:3:1) 
    ...

Environment:

  • Node.js version: v18.20.4
  • @modelcontextprotocol/sdk version: ^1.10.2
  • Operating System: Windows

Steps to reproduce:

  1. Install dependencies using pnpm install.
  2. Run the application with pnpm run start.
  3. The application fails to start with the above error.

Expected behavior:

The application should start without any errors.

Additional context:

It seems that the @modelcontextprotocol/sdk package does not properly define an exports field in its package.json, which causes Node.js to throw an ERR_PACKAGE_PATH_NOT_EXPORTED error when attempting to import from the package.

Could you please look into this and provide guidance or a fix?

Possible Solution:

  • Verify that the exports field is correctly set in the package.json of @modelcontextprotocol/sdk.
  • Alternatively, if you know of any workaround or patch, please let me know.

Thank you!

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