{"record":{"id":"6414405b16596ca2","repo":"affaan-m/ECC","slug":"typescript-compiler-not-found-install-root-dev-de","errorCode":null,"errorMessage":"TypeScript compiler not found. Install root dev dependencies before publishing so .opencode/dist can be built.","messagePattern":"TypeScript compiler not found\\. Install root dev dependencies before publishing so \\.opencode/dist can be built\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/build-opencode.js","lineNumber":18,"sourceCode":"#!/usr/bin/env node\n\nconst fs = require(\"node:fs\")\nconst path = require(\"node:path\")\nconst { execFileSync } = require(\"node:child_process\")\n\nconst rootDir = path.resolve(__dirname, \"..\")\nconst opencodeDir = path.join(rootDir, \".opencode\")\nconst distDir = path.join(opencodeDir, \"dist\")\n\nfs.rmSync(distDir, { recursive: true, force: true })\n\nlet tscEntrypoint\n\ntry {\n  tscEntrypoint = require.resolve(\"typescript/bin/tsc\", { paths: [rootDir] })\n} catch {\n  throw new Error(\n    \"TypeScript compiler not found. Install root dev dependencies before publishing so .opencode/dist can be built.\"\n  )\n}\n\nexecFileSync(process.execPath, [tscEntrypoint, \"-p\", path.join(opencodeDir, \"tsconfig.json\")], {\n  cwd: rootDir,\n  stdio: \"inherit\",\n})\n","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/build-opencode.js#L1-L27","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run npm install (or your package manager's install) at the repo root to install typescript","Verify typescript is present with `npm ls typescript` and add it via `npm i -D typescript` if missing","Ensure the publish/CI job installs devDependencies (drop --omit=dev or adjust NODE_ENV)","Re-run `node scripts/build-opencode.js` after install completes"],"exampleFix":"// before\nnode scripts/build-opencode.js\n// Error: TypeScript compiler not found...\n// after\nnpm install\nnode scripts/build-opencode.js","handlingStrategy":"validation","validationCode":"let tsc;\ntry { tsc = require.resolve('typescript/bin/tsc', { paths: [process.cwd()] }); } catch { tsc = null; }\nif (!tsc) { console.error('Run npm install first'); process.exit(1); }","typeGuard":"function hasTypeScript(rootDir) {\n  try { require.resolve('typescript/bin/tsc', { paths: [rootDir] }); return true; } catch { return false; }\n}","tryCatchPattern":"try {\n  execFileSync('node', [buildScript]);\n} catch (err) {\n  if (/TypeScript compiler not found/.test(err.message)) {\n    execFileSync('npm', ['install']);\n    execFileSync('node', [buildScript]);\n  } else throw err;\n}","preventionTips":["Run npm install on fresh clones before any build/publish step","Never publish with --omit=dev for projects requiring tsc","Pin typescript in devDependencies","Add a preflight install check to CI pipelines"],"tags":["typescript","build","missing-dependency"],"backgroundTag":"missing-dependency","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}