From e18a5bf9fd9a7ee05d022ea6035e8656204f7afe Mon Sep 17 00:00:00 2001 From: Atlantic Platform Group Date: Thu, 28 May 2026 15:08:45 -0400 Subject: [PATCH] fix(dev): force NODE_ENV=development in api dev script, modernize shared tsconfig, warn on production NODE_ENV during setup - packages/api/package.json: dev script now sets NODE_ENV=development so the API no longer crashes when the user's shell has NODE_ENV=production. The rate limiter requires Redis in production mode; local dev should never need Redis. - packages/shared/tsconfig.json: switch from commonjs/node to NodeNext/ NodeNext. Removes the TypeScript 5.x deprecation warning about commonjs with ES2022 target, and aligns with the package's existing conditional exports. - scripts/setup.mjs: add checkNodeEnv() that warns if NODE_ENV=production is detected during setup, and suggests unsetting it. Step count bumped from 8 to 9. --- packages/api/package.json | 2 +- packages/shared/tsconfig.json | 4 ++-- scripts/setup.mjs | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/packages/api/package.json b/packages/api/package.json index 1405f81..2b1c636 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -6,7 +6,7 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { - "dev": "tsx watch src/index.ts", + "dev": "NODE_ENV=development tsx watch src/index.ts", "build": "tsc", "type-check": "tsc --noEmit", "typecheck": "npm run type-check", diff --git a/packages/shared/tsconfig.json b/packages/shared/tsconfig.json index 2fda235..0f9cdda 100644 --- a/packages/shared/tsconfig.json +++ b/packages/shared/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { "target": "ES2022", - "module": "commonjs", - "moduleResolution": "node", + "module": "NodeNext", + "moduleResolution": "NodeNext", "declaration": true, "declarationMap": true, "outDir": "./dist", diff --git a/scripts/setup.mjs b/scripts/setup.mjs index f12a08b..080face 100755 --- a/scripts/setup.mjs +++ b/scripts/setup.mjs @@ -104,6 +104,20 @@ async function checkNode() { success(`Node.js ${version}`); } +async function checkNodeEnv() { + if (process.env.NODE_ENV === "production") { + warn("NODE_ENV is set to 'production' in your shell."); + log(""); + log(" This will break local dev (the API requires Redis in production mode)."); + log(" The dev script now forces NODE_ENV=development, but other tools may still"); + log(" behave differently. Consider unsetting it for local development:"); + log(` ${DIM} unset NODE_ENV${RESET}`); + log(""); + } else { + success(`NODE_ENV is ${process.env.NODE_ENV || "unset"} (ok for local dev)`); + } +} + async function checkNpm() { try { const { stdout } = await run("npm", ["--version"], { silent: true }); @@ -343,11 +357,12 @@ async function verifyMigrations() { async function main() { log(`${BOLD}OriCMS Setup${RESET}\n`); - const TOTAL_STEPS = 8; + const TOTAL_STEPS = 9; let currentStep = 0; step(++currentStep, TOTAL_STEPS, "Checking prerequisites"); await checkNode(); + await checkNodeEnv(); await checkNpm(); await checkDocker(); await checkGit();