{"record":{"id":"185e81efc3af20e1","repo":"github/copilot-sdk","slug":"could-not-resolve-packagename-reinstall-githu","errorCode":null,"errorMessage":"Could not resolve ${packageName}. Reinstall @github/copilot-sdk so its platform package is installed.","messagePattern":"Could not resolve (.+?)\\. Reinstall @github/copilot-sdk so its platform package is installed\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodejs/src/runtimeArtifacts.ts","lineNumber":278,"sourceCode":"        const packageRoot = resolvePackageRoot(packageName, options.packageSearchPaths);\n        if (!packageRoot) {\n            throw new Error(`Could not resolve ${packageName} for Copilot CLI ${version}.`);\n        }\n        validateFile(\n            join(packageRoot, \"prebuilds\", platform, \"runtime.node\"),\n            \"Copilot runtime.node\"\n        );\n        return materializeRuntimeBundle(\n            { packageRoot, platform },\n            options.cacheRoot,\n            `${version}-${platform}`\n        );\n    }\n\n    const packageName = getRuntimePackageName(platform);\n    const packageRoot = resolvePackageRoot(packageName, options.packageSearchPaths);\n    if (!packageRoot) {\n        throw new Error(\n            `Could not resolve ${packageName}. Reinstall @github/copilot-sdk so its platform package is installed.`\n        );\n    }\n    const wrapperName = platform.startsWith(\"win32\") ? \"copilot-runtime.exe\" : \"copilot-runtime\";\n    const prebuildDir = join(packageRoot, \"prebuilds\", platform);\n    const wrapper = join(prebuildDir, wrapperName);\n    try {\n        validateRuntimeBundle(wrapper, join(prebuildDir, \"runtime.node\"));\n    } catch (error) {\n        throw new Error(\n            `${packageName} is missing required Copilot CLI runtime files. Reinstall @github/copilot-sdk.`,\n            { cause: error }\n        );\n    }\n    makeExecutable(wrapper);\n    return wrapper;\n}\n","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/nodejs/src/runtimeArtifacts.ts#L260-L296","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Reinstall the SDK so optionalDependencies are installed: npm install @github/copilot-sdk.","Delete node_modules and package-lock.json, then npm install (fixes stale cross-platform lockfiles).","Run without --omit=optional/--no-optional flags.","Verify the expected platform package exists in node_modules (@github/copilot-<platform>)."],"exampleFix":"// before\nnode_modules/@github/copilot-darwin-arm64  # absent\n\n// after\nrm -rf node_modules package-lock.json\nnpm install @github/copilot-sdk","handlingStrategy":"validation","validationCode":"import { existsSync } from 'fs';\nimport { getRuntimePackageName, getRuntimePlatform } from './runtimeArtifacts';\nif (!existsSync(`node_modules/${getRuntimePackageName(getRuntimePlatform())}`)) {\n  throw new Error('platform package missing; run npm install @github/copilot-sdk');\n}","typeGuard":null,"tryCatchPattern":"try {\n  const path = runtimePath();\n} catch (e) {\n  if (e.message.includes('Reinstall @github/copilot-sdk')) {\n    // surface reinstall instructions to the user\n  } else throw e;\n}","preventionTips":["Regenerate package-lock.json on the target platform/arch.","Avoid --no-optional; verify optional deps after install.","Reinstall the SDK whenever switching OS/arch (docker builds, CI runners)."],"tags":["npm","optional-dependencies","install","platform-package","nodejs"],"backgroundTag":"missing-optional-dependency","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}