affaan-m/ECC · error · Error

TypeScript compiler not found. Install root dev…

Error message

TypeScript compiler not found. Install root dev dependencies before publishing so .opencode/dist can be built.

What it means

scripts/build-opencode.js compiles the .opencode workspace with tsc before publishing. It resolves 'typescript/bin/tsc' against the repo root; if resolution fails, TypeScript is not installed in root devDependencies, and the script throws with instructions instead of failing cryptically later.

Solutions

  1. Run npm install (or your package manager's install) at the repo root to install typescript
  2. Verify typescript is present with `npm ls typescript` and add it via `npm i -D typescript` if missing
  3. Ensure the publish/CI job installs devDependencies (drop --omit=dev or adjust NODE_ENV)
  4. Re-run `node scripts/build-opencode.js` after install completes

Example fix

// before
node scripts/build-opencode.js
// Error: TypeScript compiler not found...
// after
npm install
node scripts/build-opencode.js
Defensive patterns

Strategy: validation

Validate before calling

let tsc;
try { tsc = require.resolve('typescript/bin/tsc', { paths: [process.cwd()] }); } catch { tsc = null; }
if (!tsc) { console.error('Run npm install first'); process.exit(1); }

Type guard

function hasTypeScript(rootDir) {
  try { require.resolve('typescript/bin/tsc', { paths: [rootDir] }); return true; } catch { return false; }
}

Try / catch

try {
  execFileSync('node', [buildScript]);
} catch (err) {
  if (/TypeScript compiler not found/.test(err.message)) {
    execFileSync('npm', ['install']);
    execFileSync('node', [buildScript]);
  } else throw err;
}

Prevention

When it happens

Trigger: Running scripts/build-opencode.js (or any npm lifecycle that invokes it) with node_modules not installed, typescript removed from devDependencies, or running from a pruned/production-only install.

Common situations: Fresh clone where npm install was skipped; publishing pipeline running with NODE_ENV=production and --omit=dev; partial node_modules after a failed install or a yarn/pnpm switch leaving stale state.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/6414405b16596ca2. Report an issue: GitHub.

Appendix: source

Thrown at scripts/build-opencode.js:18

#!/usr/bin/env node

const fs = require("node:fs")
const path = require("node:path")
const { execFileSync } = require("node:child_process")

const rootDir = path.resolve(__dirname, "..")
const opencodeDir = path.join(rootDir, ".opencode")
const distDir = path.join(opencodeDir, "dist")

fs.rmSync(distDir, { recursive: true, force: true })

let tscEntrypoint

try {
  tscEntrypoint = require.resolve("typescript/bin/tsc", { paths: [rootDir] })
} catch {
  throw new Error(
    "TypeScript compiler not found. Install root dev dependencies before publishing so .opencode/dist can be built."
  )
}

execFileSync(process.execPath, [tscEntrypoint, "-p", path.join(opencodeDir, "tsconfig.json")], {
  cwd: rootDir,
  stdio: "inherit",
})

View on GitHub (pinned to 8321021c54)