{"record":{"id":"938736b20838ce1d","repo":"stablyai/orca","slug":"compiled-cli-package-boundary-is-missing-path-r","errorCode":null,"errorMessage":"compiled CLI package boundary is missing: ${path.relative(projectDir, outPackageJsonPath)}","messagePattern":"compiled CLI package boundary is missing: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/scripts/verify-cli-bin.mjs","lineNumber":59,"sourceCode":"    throw new Error(`bin.orca target is empty: ${binTarget}`)\n  }\n\n  const content = readFileSync(binPath, 'utf8')\n  if (!content.startsWith('#!/usr/bin/env node\\n')) {\n    throw new Error(`bin.orca target must start with a Node shebang: ${binTarget}`)\n  }\n\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    }","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/config/scripts/verify-cli-bin.mjs#L41-L77","documentation":"The compiled CLI tree must carry an out/package.json that establishes the CommonJS module boundary the packaged CLI loads at runtime. When readFileSync throws ENOENT for out/package.json (and fixPackageJson was not set, since that flag writes it first), the verifier reports the missing boundary as a build defect rather than rethrowing the raw ENOENT. Without this file Node would resolve the out/ tree under the root package.json's module type, which can mismatch the compiled output.","triggerScenarios":"JSON.parse(readFileSync('out/package.json')) throws an error with code === 'ENOENT' at line 58. Happens when the build never emitted out/package.json and --fix-package-json was not passed.","commonSituations":"Running verify-cli-bin without --fix-package-json on a fresh build that doesn't copy/write the boundary file; a build refactor that stopped emitting out/package.json.","solutions":["Re-run verify-cli-bin with --fix-package-json to have it write the canonical CommonJS boundary file.","Or ensure the build pipeline writes out/package.json with `{ \"type\": \"commonjs\", \"private\": true }`.","Re-run without flags to confirm the file now exists and parses."],"exampleFix":"# before\nnode config/scripts/verify-cli-bin.mjs\n# after\nnode config/scripts/verify-cli-bin.mjs --fix-package-json","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs'\nconst outPkg = path.join(projectDir, 'out', 'package.json')\nif (!existsSync(outPkg)) {\n  // let the verifier fix it, or write the boundary yourself\n  console.error('out/package.json missing — run verify-cli-bin --fix-package-json')\n}","typeGuard":null,"tryCatchPattern":"try {\n  outPackageJson = JSON.parse(readFileSync(outPackageJsonPath, 'utf8'))\n} catch (error) {\n  if (error?.code === 'ENOENT') {\n    // auto-fix instead of failing\n    mkdirSync(path.dirname(outPackageJsonPath), { recursive: true })\n    writeFileSync(outPackageJsonPath, OUT_COMMONJS_PACKAGE_JSON, 'utf8')\n    outPackageJson = JSON.parse(readFileSync(outPackageJsonPath, 'utf8'))\n  } else throw error\n}","preventionTips":["Run verify-cli-bin --fix-package-json in the build pipeline so the boundary is always emitted.","Never copy the root (ESM) package.json into out/."],"tags":["cli","packaging","commonjs","module-boundary","package-json"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}