From dcce160a4dfaf842289ae0ef4e77c15514783741 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 1 Aug 2026 14:13:10 +0000 Subject: [PATCH] fix(ci): lazy-load dotenv in cli.mjs for deploy cooldown vercel-deploy-cooldown.mjs only needs dieWithLabel from cli.mjs, but the module eagerly imported dotenv. The deploy job runs the cooldown check before pnpm install, so Node failed with ERR_MODULE_NOT_FOUND. Require dotenv inside loadCliEnv() so lightweight CI steps can import dieWithLabel without node_modules. --- scripts/lib/cli.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/lib/cli.mjs b/scripts/lib/cli.mjs index d5bbb6b8..847300e3 100644 --- a/scripts/lib/cli.mjs +++ b/scripts/lib/cli.mjs @@ -8,9 +8,10 @@ */ import { createHash } from 'node:crypto' import { access, mkdir, readFile, writeFile } from 'node:fs/promises' +import { createRequire } from 'node:module' import { dirname, join } from 'node:path' -import { config as loadEnv } from 'dotenv' +const require = createRequire(import.meta.url) /** Labelled `die` factory: `dieWithLabel('seed:tse')` → the script's `die`. */ export const dieWithLabel = (label) => (message) => { @@ -22,6 +23,7 @@ export const sha256Hex = (buffer) => createHash('sha256').update(buffer).digest( /** The dotenv preamble every DB-touching script needs (.env.local wins over .env). */ export const loadCliEnv = () => { + const { config: loadEnv } = require('dotenv') loadEnv({ path: '.env.local' }) loadEnv({ path: '.env' }) }