Skip to content

ERR_MODULE_NOT_FOUND in 0.1.31: session.js missing .js extension on vscode-jsonrpc/node import #707

Closed

Description

Bug

@github/copilot-sdk@0.1.31 crashes on startup under Node.js v24 due to a missing .js file extension on a new import added to dist/session.js.

Same class of defect as #8 (fixed in 0.1.10/0.1.11 for client.js).

Error

Error [ERR_MODULE_NOT_FOUND]: Cannot find module
  '.../node_modules/vscode-jsonrpc/node'
  imported from .../node_modules/@github/copilot-sdk/dist/session.js
Did you mean to import "vscode-jsonrpc/node.js"?

Root Cause

SDK 0.1.31 added a new import to dist/session.js (not present in 0.1.29) that omits the .js extension:

# 0.1.31 session.js line 1 -- NEW import, missing .js
import { ConnectionError, ResponseError } from "vscode-jsonrpc/node";

# 0.1.31 client.js line 10 -- existing import, correct
} from "vscode-jsonrpc/node.js";

The SDK declares "type": "module" (ESM). The dependency vscode-jsonrpc@8.2.1 has no exports map and no "type" field. Without an exports map, Node ESM resolution does not auto-append .js for subpath imports, so "vscode-jsonrpc/node" fails to resolve even though node.js exists in the package root.

dist/client.js already uses the correct "vscode-jsonrpc/node.js" form -- the new session.js import simply did not follow the same convention.

Diff: 0.1.29 / 0.1.30 vs 0.1.31

File 0.1.29 0.1.30 0.1.31
dist/session.js No vscode-jsonrpc import No vscode-jsonrpc import import { ConnectionError, ResponseError } from "vscode-jsonrpc/node" (missing .js)
dist/client.js from "vscode-jsonrpc/node.js" from "vscode-jsonrpc/node.js" from "vscode-jsonrpc/node.js" (unchanged, correct)

Environment

  • Affected: 0.1.31
  • Working: 0.1.29, 0.1.30
  • Node.js: v24.14.0
  • OS: Linux

Workaround

Pin to 0.1.30 (or 0.1.29):

"@github/copilot-sdk": "0.1.30"

Suggested Fix

Add .js to the import in the source that produces dist/session.js:

import { ConnectionError, ResponseError } from "vscode-jsonrpc/node.js";

Activity

  1. theblixguy commented on Mar 7, 2026

    @theblixguy

    I also ran into this in our test suite (vitest with Node ESM). There's another workaround which involves registering a custom module resolution hook before the SDK gets imported:

    // filename: fix-jsonrpc-import.js
    
    import { register } from "node:module";
    
    register(
      "data:text/javascript," +
        encodeURIComponent(`
          export function resolve(specifier, context, nextResolve) {
            if (specifier === "vscode-jsonrpc/node") {
              return nextResolve("vscode-jsonrpc/node.js", context);
            }
            return nextResolve(specifier, context);
          }
        `),
      import.meta.url,
    );

    For vitest, you can drop this in a file and add it to the setupFiles in your config. For plain Node, you can pass it with --import ./fix-jsonrpc-import.js. The hook will intercept the bare vscode-jsonrpc/node specifier and appends .js before Node's default resolver sees it.

    It's worth noting that this only affects ESM contexts where Node enforces strict specifier resolution. CJS works fine and so do bundlers like tsx, since they handle extension-less imports on their own.

  2. added 2 commits that reference this issue on Mar 9, 2026
    790e733
    5f78d8c
  3. Rubiss commented on Mar 14, 2026

    @Rubiss

    Still present in v0.1.32, also reproducible on Node 22

    Confirming this bug is not fixed in v0.1.32 (latest as of 2026-03-14). The bad import is unchanged in the published package:

    $ npm show @github/copilot-sdk version
    0.1.32
    
    $ node -e "require('fs').readFileSync(require.resolve('@github/copilot-sdk/dist/session.js'), 'utf8').split('\n').slice(0,1).forEach(l => console.log(l))"
    import { ConnectionError, ResponseError } from "vscode-jsonrpc/node";
    

    Additional environment data

    Field Value
    @github/copilot-sdk 0.1.32
    vscode-jsonrpc 8.2.1
    Node.js v22.22.0 (also fails on v22, not just v24)
    OS Linux (WSL2)

    The error is identical to what #707 describes — Node 22's strict ESM resolver also refuses to auto-append .js for subpath imports on packages without an exports map.

    Workaround for npm-installed packages

    As an alternative to the module hook in the previous comment, a postinstall script can patch the file in place (no runtime overhead):

    // postinstall patch (CJS, no deps required)
    const fs = require('fs'), path = require('path');
    const f = path.resolve(process.cwd(), 'node_modules/@github/copilot-sdk/dist/session.js');
    try {
      const s = fs.readFileSync(f, 'utf8');
      fs.writeFileSync(f, s.replace('from "vscode-jsonrpc/node"', 'from "vscode-jsonrpc/node.js"'));
    } catch (_) {}

    This is idempotent and non-fatal if the file is absent. Hoping for an official fix in 0.1.33+.

  4. norrisp90 commented on Mar 14, 2026

    @norrisp90

    Confirming on Node 22 with @github/copilot-sdk@0.1.32 + vscode-jsonrpc@8.2.1 in a CommonJS Express server that dynamic-imports the SDK.

    We settled on patch-package as the workaround — it's the lightest touch and works cleanly in Docker builds:

    // package.json
    {
      "scripts": { "postinstall": "npx patch-package" },
      "devDependencies": { "patch-package": "^8.0.0" }
    }
    # patches/@github+copilot-sdk+0.1.32.patch
    --- a/node_modules/@github/copilot-sdk/dist/session.js
    +++ b/node_modules/@github/copilot-sdk/dist/session.js
    @@ -1,4 +1,4 @@
    -import { ConnectionError, ResponseError } from "vscode-jsonrpc/node";
    +import { ConnectionError, ResponseError } from "vscode-jsonrpc/node.js";
     import { createSessionRpc } from "./generated/rpc.js";

    No runtime hooks, no version overrides, auto-applies on npm install, and self-removes when the SDK ships the fix.

  5. theblixguy commented on Mar 14, 2026

    @theblixguy

    It's fixed on main but I think they haven't shipped a new release since then, so we need to wait for .33

  6. sinedied commented on Mar 19, 2026

    @sinedied
    Contributor

    Bumping this, the issue is already fixed so would it be possible to publish a new version? This is currently blocking

  7. patniko commented on Mar 19, 2026

    @patniko
    Contributor

    Coming. We are combining a few breaking changes and releases for integrators at the moment. Expect a rev to 0.2.xx within the next day.

  8. SteveSandersonMS commented on Mar 19, 2026

    @SteveSandersonMS
    Contributor

    Yohan Lasorsa (@sinedied) Just shipped 0.1.33-preview.3 to NPM - please let us know if you still run into this issue.

  9. sinedied commented on Mar 20, 2026

    @sinedied
    Contributor

    Steve Sanderson (@SteveSandersonMS) updated, tested it fixed the issue thanks!

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

    needs-investigationRoot cause unclear, needs human review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions