From 62cd42b30f68bc065d3e14dbdd39e792b549116a Mon Sep 17 00:00:00 2001 From: suraj-markup Date: Mon, 2 Mar 2026 02:50:56 +0530 Subject: [PATCH] fix: resolve checkBuilt from web node_modules and remove unused imports Check ao-core/dist/index.js relative to webDir's node_modules instead of using require.resolve which fails under npm link. Also removes unused existsSync/resolve/createRequire imports that caused lint errors. Co-Authored-By: Claude Opus 4.6 --- packages/cli/src/commands/start.ts | 2 +- packages/cli/src/lib/preflight.ts | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/cli/src/commands/start.ts b/packages/cli/src/commands/start.ts index 1a4947e5a..a0889246a 100644 --- a/packages/cli/src/commands/start.ts +++ b/packages/cli/src/commands/start.ts @@ -153,7 +153,7 @@ export function registerStart(program: Command): void { if (!existsSync(resolve(webDir, "package.json"))) { throw new Error("Could not find @composio/ao-web package. Run: pnpm install"); } - await preflight.checkBuilt(); + await preflight.checkBuilt(webDir); if (opts?.rebuild) { await cleanNextCache(webDir); diff --git a/packages/cli/src/lib/preflight.ts b/packages/cli/src/lib/preflight.ts index c424759e3..d3879a28b 100644 --- a/packages/cli/src/lib/preflight.ts +++ b/packages/cli/src/lib/preflight.ts @@ -9,7 +9,6 @@ import { existsSync } from "node:fs"; import { resolve } from "node:path"; -import { createRequire } from "node:module"; import { isPortAvailable } from "./web-dir.js"; import { exec } from "./shell.js"; @@ -28,16 +27,13 @@ async function checkPort(port: number): Promise { /** * Check that workspace packages have been compiled (TypeScript → JavaScript). - * Verifies @composio/ao-core dist output exists, since a missing dist/ is the - * actual cause of module resolution errors when starting the dashboard. - * Works with both `next dev` and `next build` (unlike .next/BUILD_ID which - * is production-only). + * Verifies @composio/ao-core dist output exists from the web package's + * node_modules, since a missing dist/ causes module resolution errors when + * starting the dashboard. Works with both `next dev` and `next build`. */ -async function checkBuilt(): Promise { - const require = createRequire(import.meta.url); - try { - require.resolve("@composio/ao-core"); - } catch { +async function checkBuilt(webDir: string): Promise { + const coreEntry = resolve(webDir, "node_modules", "@composio", "ao-core", "dist", "index.js"); + if (!existsSync(coreEntry)) { throw new Error("Packages not built. Run: pnpm build"); } }