Skip to content

ERR_MODULE_NOT_FOUND: CLI fails to locate package.json when starting inspector with --cli flag #834

@mbhargav294

Description

@mbhargav294

Inspector Version

  • 0.17.0

Describe the bug
When attempting to install and run @modelcontextprotocol/inspector, the process fails with an ERR_MODULE_NOT_FOUND error. The error indicates that the package's CLI cannot find its required package.json file.

To Reproduce
Steps to reproduce the behavior:

  1. Run the npx command to install @modelcontextprotocol/[email protected]
  2. Confirm installation prompt with 'y'
  3. Observe the error when the package attempts to execute

Expected behavior
The package should install and run successfully without any module resolution errors.

Environment (please complete the following information):

  • OS: macOS
  • Node.js: v22.20.0

Additional context
Full error stack trace shows that the issue occurs during ESM module resolution. The error specifically relates to not being able to find the package.json file at the path:
/Users/********/.npm/_npx/****************/node_modules/@modelcontextprotocol/inspector/cli/package.json

Full command:

npx @modelcontextprotocol/inspector \
    --cli \
    https://my.streamable.http.server/mcp \
    --transport http \
    --method tools/list \
    --header "Authorization: MyBerarToken"

Full command output:

Need to install the following packages:
@modelcontextprotocol/[email protected]
Ok to proceed? (y) y

npm warn deprecated [email protected]: Use your platform's native DOMException instead
node:internal/modules/esm/resolve:274
    throw new ERR_MODULE_NOT_FOUND(
          ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/********/.npm/_npx/*************/node_modules/@modelcontextprotocol/inspector/cli/package.json' imported from /Users/********/.npm/_npx/*************/node_modules/@modelcontextprotocol/inspector/cli/build/index.js
    at finalizeResolution (node:internal/modules/esm/resolve:274:11)
    at moduleResolve (node:internal/modules/esm/resolve:859:10)
    at defaultResolve (node:internal/modules/esm/resolve:983:11)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:731:20)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
    at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:310:38)
    at ModuleJob._link (node:internal/modules/esm/module_job:183:49) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///Users/********/.npm/_npx/*************/node_modules/@modelcontextprotocol/inspector/cli/package.json'
}

Node.js v22.20.0

Failed with exit code: 1

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