github/copilot-sdk · error

Could not resolve . Reinstall @github/copilot-sdk so its…

Error message

Could not resolve ${packageName}. Reinstall @github/copilot-sdk so its platform package is installed.

What it means

In the default (non-npm) path, ensureRuntimeBundle resolves the platform runtime package (getRuntimePackageName) and throws this error when it is absent, instructing the user to reinstall @github/copilot-sdk so its platform package is installed. The platform package ships the copilot-runtime wrapper binary and runtime.node.

Solutions

  1. Reinstall the SDK so optionalDependencies are installed: npm install @github/copilot-sdk.
  2. Delete node_modules and package-lock.json, then npm install (fixes stale cross-platform lockfiles).
  3. Run without --omit=optional/--no-optional flags.
  4. Verify the expected platform package exists in node_modules (@github/copilot-<platform>).

Example fix

// before
node_modules/@github/copilot-darwin-arm64  # absent

// after
rm -rf node_modules package-lock.json
npm install @github/copilot-sdk
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from 'fs';
import { getRuntimePackageName, getRuntimePlatform } from './runtimeArtifacts';
if (!existsSync(`node_modules/${getRuntimePackageName(getRuntimePlatform())}`)) {
  throw new Error('platform package missing; run npm install @github/copilot-sdk');
}

Try / catch

try {
  const path = runtimePath();
} catch (e) {
  if (e.message.includes('Reinstall @github/copilot-sdk')) {
    // surface reinstall instructions to the user
  } else throw e;
}

Prevention

When it happens

Trigger: resolvePackageRoot returns null for the platform package (e.g. @github/copilot-darwin-arm64) when getBundledRuntimePath or runtimePath is called — package never installed, pruned, or not in the search paths.

Common situations: Installing with --no-optional or --omit=optional (platform packages are optionalDependencies), npm bug skipping optional deps with package-lock from another platform, copying node_modules across OSes, lockfile generated on a different arch.

Understand the failure class

Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.

Related errors


AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09). Data as JSON: /api/errors/185e81efc3af20e1. Report an issue: GitHub.

Appendix: source

Thrown at nodejs/src/runtimeArtifacts.ts:278

        const packageRoot = resolvePackageRoot(packageName, options.packageSearchPaths);
        if (!packageRoot) {
            throw new Error(`Could not resolve ${packageName} for Copilot CLI ${version}.`);
        }
        validateFile(
            join(packageRoot, "prebuilds", platform, "runtime.node"),
            "Copilot runtime.node"
        );
        return materializeRuntimeBundle(
            { packageRoot, platform },
            options.cacheRoot,
            `${version}-${platform}`
        );
    }

    const packageName = getRuntimePackageName(platform);
    const packageRoot = resolvePackageRoot(packageName, options.packageSearchPaths);
    if (!packageRoot) {
        throw new Error(
            `Could not resolve ${packageName}. Reinstall @github/copilot-sdk so its platform package is installed.`
        );
    }
    const wrapperName = platform.startsWith("win32") ? "copilot-runtime.exe" : "copilot-runtime";
    const prebuildDir = join(packageRoot, "prebuilds", platform);
    const wrapper = join(prebuildDir, wrapperName);
    try {
        validateRuntimeBundle(wrapper, join(prebuildDir, "runtime.node"));
    } catch (error) {
        throw new Error(
            `${packageName} is missing required Copilot CLI runtime files. Reinstall @github/copilot-sdk.`,
            { cause: error }
        );
    }
    makeExecutable(wrapper);
    return wrapper;
}

View on GitHub (pinned to cd8cf15dc3)