Skip to content

Build error adding sdk to project #902

@ArkeBcacy

Description

@ArkeBcacy

Describe the bug
Going through the tutorial here and when I run npm start the command fails with the error:

PS C:\Prj\MCP\Server\Weather> npm start                                   

> weather-mcp-server@1.0.0 start
> node build/index.js

node:internal/modules/esm/resolve:215
  const resolvedOption = FSLegacyMainResolve(packageJsonUrlString, packageConfig.main, baseStringified);
                         ^

Error: Cannot find package 'C:\Prj\MCP\Server\Weather\node_modules\@modelcontextprotocol\sdk\package.json' imported from C:\Prj\MCP\Server\Weather\build\index.js
    at legacyMainResolve (node:internal/modules/esm/resolve:215:26)
    at packageResolve (node:internal/modules/esm/resolve:841:14)
    at moduleResolve (node:internal/modules/esm/resolve:927:18)
    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 ModuleLoader.import (node:internal/modules/esm/loader:315:34)
    at importModuleDynamically (node:internal/modules/esm/translators:161:31)
    at importModuleDynamicallyCallback (node:internal/modules/esm/utils:222:14) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Attempted to build the latest 1.17.4 SDK code locally and received the error:

PS C:\Prj\MCP\SDK\TS\typescript-sdk> npm run build

> @modelcontextprotocol/sdk@1.17.4 build
> npm run build:esm && npm run build:cjs


> @modelcontextprotocol/sdk@1.17.4 build:esm
> mkdir -p dist/esm && echo '{"type": "module"}' > dist/esm/package.json && tsc -p tsconfig.prod.json

The syntax of the command is incorrect.

To Reproduce
Steps to reproduce the behavior:

  1. Cloaned the GIT Repo
  2. Ran npm install
  3. Ran npm build

Expected behavior
Expectation is that the typescript sdk works when pulling it into a project as outlined in the documentation

Running this with Windows 11 and latest VS Code for reference.

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