{"record":{"id":"866f1f28f49699cc","repo":"stablyai/orca","slug":"compiled-cli-package-boundary-must-declare-type-co","errorCode":null,"errorMessage":"compiled CLI package boundary must declare type=commonjs: ${path.relative(projectDir, outPackageJsonPath)}","messagePattern":"compiled CLI package boundary must declare type=commonjs: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/scripts/verify-cli-bin.mjs","lineNumber":66,"sourceCode":"\n  const outPackageJsonPath = path.join(projectDir, 'out', 'package.json')\n  if (fixPackageJson) {\n    mkdirSync(path.dirname(outPackageJsonPath), { recursive: true })\n    writeFileSync(outPackageJsonPath, OUT_COMMONJS_PACKAGE_JSON, 'utf8')\n  }\n  let outPackageJson\n  try {\n    outPackageJson = JSON.parse(readFileSync(outPackageJsonPath, 'utf8'))\n  } catch (error) {\n    if (error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT') {\n      throw new Error(\n        `compiled CLI package boundary is missing: ${path.relative(projectDir, outPackageJsonPath)}`\n      )\n    }\n    throw error\n  }\n  if (outPackageJson.type !== 'commonjs') {\n    throw new Error(\n      `compiled CLI package boundary must declare type=commonjs: ${path.relative(\n        projectDir,\n        outPackageJsonPath\n      )}`\n    )\n  }\n\n  if (process.platform !== 'win32' && (stats.mode & 0o111) === 0) {\n    if (!fixExecutable) {\n      throw new Error(`bin.orca target is not executable: ${binTarget}`)\n    }\n    chmodSync(binPath, stats.mode | 0o755)\n  }\n\n  if (runHelp) {\n    execFileSync(process.execPath, [binPath, '--help'], {\n      cwd: projectDir,\n      stdio: 'ignore'","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/verify-cli-bin.mjs#L48-L84","documentation":"out/package.json exists and parses but its `type` field is not 'commonjs'. The compiled CLI output is CommonJS, so the package boundary must declare type=commonjs to prevent Node from interpreting .js files in out/ as ESM (which would crash require()/module.exports usage). The verifier fails closed here to block a release where the module type would mismatch the compiled code.","triggerScenarios":"outPackageJson.type !== 'commonjs' at line 65. Caused by out/package.json declaring `\"type\": \"module\"`, omitting `type` while the root package.json is ESM, or a stale/misgenerated boundary file.","commonSituations":"A build step that copies the root package.json (which may be type:module) into out/ verbatim; hand-editing out/package.json; a tool that regenerates it without the type field.","solutions":["Run verify-cli-bin with --fix-package-json to overwrite out/package.json with the canonical CommonJS boundary.","Or set `\"type\": \"commonjs\"` in out/package.json in the build pipeline.","Confirm the build is not copying the root (ESM) package.json into out/."],"exampleFix":"// before: out/package.json\n{ \"name\": \"orca-compiled-output\", \"type\": \"module\" }\n// after\n{ \"name\": \"orca-compiled-output\", \"type\": \"commonjs\", \"private\": true }","handlingStrategy":"validation","validationCode":"const outPkg = JSON.parse(readFileSync('out/package.json', 'utf8'))\nif (outPkg.type !== 'commonjs') {\n  throw new Error('out/package.json must declare type=commonjs for the compiled CLI')\n}","typeGuard":"function isCommonJsBoundary(pkg: unknown): boolean {\n  return typeof pkg === 'object' && pkg !== null && (pkg as any).type === 'commonjs'\n}","tryCatchPattern":null,"preventionTips":["Always pass --fix-package-json in CI to keep the boundary canonical.","Audit any build step that writes out/package.json."],"tags":["cli","packaging","commonjs","esm","module-boundary"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}