Skip to content

ERR_MODULE_NOT_FOUND When Importing from proxyProvider Without .js Extension #440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
KD23243 opened this issue May 3, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@KD23243
Copy link

KD23243 commented May 3, 2025

Describe the bug
Following the example in the README section on proxy authorization leads to a ERR_MODULE_NOT_FOUND error when importing from @modelcontextprotocol/sdk/server/auth/providers/proxyProvider.

To Reproduce
Steps to reproduce the behavior:

  1. Follow the example import:
import { ProxyOAuthServerProvider, mcpAuthRouter } from '@modelcontextprotocol/sdk/server/auth/providers/proxyProvider';
  1. Run the Node.js project (using ESM).

Expected behavior
The import should resolve correctly and not throw a ERR_MODULE_NOT_FOUND error.

Logs

node:internal/modules/esm/resolve:265
    throw new ERR_MODULE_NOT_FOUND(
          ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/kumuditha/Documents/mcpHackerthon/my/untitled folder/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/providers/proxyProvider' imported from /Users/kumuditha/Documents/mcpHackerthon/my/untitled folder/client.js
    at finalizeResolution (node:internal/modules/esm/resolve:265:11)
    at moduleResolve (node:internal/modules/esm/resolve:933:10)
    at defaultResolve (node:internal/modules/esm/resolve:1169:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:383:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:352:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:227:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:87:39)
    at link (node:internal/modules/esm/module_job:86:36) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///Users/kumuditha/Documents/mcpHackerthon/my/untitled%20folder/node_modules/@modelcontextprotocol/sdk/dist/esm/server/auth/providers/proxyProvider'
}

Additional context
Modifying the import to include the .js extension resolved the issue:

import { mcpAuthRouter } from '@modelcontextprotocol/sdk/server/auth/router.js';
import { ProxyOAuthServerProvider } from '@modelcontextprotocol/sdk/server/auth/providers/proxyProvider.js';

This may require either fixing the documentation example or updating the SDK’s exports field in package.json to support extensionless ESM imports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant