diff --git a/cli/src/commands/run.ts b/cli/src/commands/run.ts index 6d6ccae2..6e061b2e 100644 --- a/cli/src/commands/run.ts +++ b/cli/src/commands/run.ts @@ -84,6 +84,15 @@ function isModuleNotFoundError(err: unknown): boolean { return err.message.includes("Cannot find module"); } +function getMissingModuleSpecifier(err: unknown): string | null { + if (!(err instanceof Error)) return null; + const packageMatch = err.message.match(/Cannot find package '([^']+)' imported from/); + if (packageMatch?.[1]) return packageMatch[1]; + const moduleMatch = err.message.match(/Cannot find module '([^']+)'/); + if (moduleMatch?.[1]) return moduleMatch[1]; + return null; +} + function maybeEnableUiDevMiddleware(entrypoint: string): void { if (process.env.PAPERCLIP_UI_DEV_MIDDLEWARE !== undefined) return; const normalized = entrypoint.replaceAll("\\", "/"); @@ -106,7 +115,9 @@ async function importServerEntry(): Promise { try { await import("@paperclipai/server"); } catch (err) { - if (isModuleNotFoundError(err)) { + const missingSpecifier = getMissingModuleSpecifier(err); + const missingServerEntrypoint = !missingSpecifier || missingSpecifier === "@paperclipai/server"; + if (isModuleNotFoundError(err) && missingServerEntrypoint) { throw new Error( `Could not locate a Paperclip server entrypoint.\n` + `Tried: ${devEntry}, @paperclipai/server\n` + diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 304bb691..f04df9b8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -174,7 +174,7 @@ importers: specifier: workspace:* version: link:../packages/shared better-auth: - specifier: ^1.3.8 + specifier: 1.4.18 version: 1.4.18(drizzle-kit@0.31.9)(drizzle-orm@0.38.4(@electric-sql/pglite@0.3.15)(@types/react@19.2.14)(kysely@0.28.11)(pg@8.18.0)(postgres@3.4.8)(react@19.2.4))(pg@8.18.0)(react-dom@19.2.4(react@19.2.4))(react@19.2.4)(vitest@3.2.4(@types/debug@4.1.12)(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.30.2)(tsx@4.21.0)) detect-port: specifier: ^2.1.0 diff --git a/server/package.json b/server/package.json index df87aca2..6e3bfd3c 100644 --- a/server/package.json +++ b/server/package.json @@ -37,7 +37,7 @@ "@paperclipai/adapter-utils": "workspace:*", "@paperclipai/db": "workspace:*", "@paperclipai/shared": "workspace:*", - "better-auth": "^1.3.8", + "better-auth": "1.4.18", "detect-port": "^2.1.0", "dotenv": "^17.0.1", "drizzle-orm": "^0.38.4",