From fcef65a73e4f6b588264b614347b7ece3edce8b9 Mon Sep 17 00:00:00 2001 From: ymc9 <104139426+ymc9@users.noreply.github.com> Date: Sat, 15 Nov 2025 08:23:57 -0800 Subject: [PATCH] fix(cli): add a npx/bunx fallback for running prisma commands --- packages/cli/src/utils/exec-utils.ts | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/cli/src/utils/exec-utils.ts b/packages/cli/src/utils/exec-utils.ts index 2ef0e26d..0e4ad3ed 100644 --- a/packages/cli/src/utils/exec-utils.ts +++ b/packages/cli/src/utils/exec-utils.ts @@ -30,13 +30,24 @@ export function execPackage( * Utility for running prisma commands */ export function execPrisma(args: string, options?: Omit & { env?: Record }) { - let prismaPath: string; - if (typeof import.meta.resolve === 'function') { - // esm - prismaPath = fileURLToPath(import.meta.resolve('prisma/build/index.js')); - } else { - // cjs - prismaPath = require.resolve('prisma/build/index.js'); + let prismaPath: string | undefined; + try { + if (typeof import.meta.resolve === 'function') { + // esm + prismaPath = fileURLToPath(import.meta.resolve('prisma/build/index.js')); + } else { + // cjs + prismaPath = require.resolve('prisma/build/index.js'); + } + } catch { + // ignore and fallback } + + if (!prismaPath) { + // fallback to npx/bunx execute + execPackage(`prisma ${args}`, options); + return; + } + execSync(`node ${prismaPath} ${args}`, options); }