stablyai/orca · error

compiled CLI package boundary must declare type=commonjs: ${

Error message

compiled CLI package boundary must declare type=commonjs: ${path.relative(projectDir, outPackageJsonPath)}

What it means

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.

Source

Thrown at config/scripts/verify-cli-bin.mjs:66

  const outPackageJsonPath = path.join(projectDir, 'out', 'package.json')
  if (fixPackageJson) {
    mkdirSync(path.dirname(outPackageJsonPath), { recursive: true })
    writeFileSync(outPackageJsonPath, OUT_COMMONJS_PACKAGE_JSON, 'utf8')
  }
  let outPackageJson
  try {
    outPackageJson = JSON.parse(readFileSync(outPackageJsonPath, 'utf8'))
  } catch (error) {
    if (error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT') {
      throw new Error(
        `compiled CLI package boundary is missing: ${path.relative(projectDir, outPackageJsonPath)}`
      )
    }
    throw error
  }
  if (outPackageJson.type !== 'commonjs') {
    throw new Error(
      `compiled CLI package boundary must declare type=commonjs: ${path.relative(
        projectDir,
        outPackageJsonPath
      )}`
    )
  }

  if (process.platform !== 'win32' && (stats.mode & 0o111) === 0) {
    if (!fixExecutable) {
      throw new Error(`bin.orca target is not executable: ${binTarget}`)
    }
    chmodSync(binPath, stats.mode | 0o755)
  }

  if (runHelp) {
    execFileSync(process.execPath, [binPath, '--help'], {
      cwd: projectDir,
      stdio: 'ignore'

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Run verify-cli-bin with --fix-package-json to overwrite out/package.json with the canonical CommonJS boundary.
  2. Or set `"type": "commonjs"` in out/package.json in the build pipeline.
  3. Confirm the build is not copying the root (ESM) package.json into out/.

Example fix

// before: out/package.json
{ "name": "orca-compiled-output", "type": "module" }
// after
{ "name": "orca-compiled-output", "type": "commonjs", "private": true }
Defensive patterns

Strategy: validation

Validate before calling

const outPkg = JSON.parse(readFileSync('out/package.json', 'utf8'))
if (outPkg.type !== 'commonjs') {
  throw new Error('out/package.json must declare type=commonjs for the compiled CLI')
}

Type guard

function isCommonJsBoundary(pkg: unknown): boolean {
  return typeof pkg === 'object' && pkg !== null && (pkg as any).type === 'commonjs'
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/866f1f28f49699cc. Report an issue: GitHub.