🐛 fix(build): guard root postinstall so it stops printing a MODULE_NOT_FOUND stack#19
Conversation
…T_FOUND stack Vercel installs the workspace root (`npm install --prefix=..`), which fires the root postinstall. `/scripts` is vercelignored, so `node scripts/install-skills.mjs` threw MODULE_NOT_FOUND and dumped a stack on every build. `|| true` swallowed the exit code but not the stack — noise that would happily hide a real failure. Check the file exists before running it. Uses `node -e` rather than `[ -f ... ]` because npm runs scripts through cmd.exe on Windows. `--soft` already guarantees exit 0, and spawnSync's status is ignored, so install still can never fail on this script. Verified both paths: with scripts/ present it runs as before (exit 0); with scripts/ absent it is silent (exit 0, no stack).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated the 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
biggest-littlest
left a comment
There was a problem hiding this comment.
Confirmed on the preview build for 9468700: zero MODULE_NOT_FOUND, postinstall runs silently, and the website still builds ┌ ○ /. node -e over [ -f ] is right for cmd.exe. install can still never fail (--soft exits 0, and spawnSync status is ignored).
ALARGECOMPANY
left a comment
There was a problem hiding this comment.
Good cleanup. Silent build logs make real failures visible.
Follow-up to #18. Every Vercel build dumps a stack trace that is swallowed but never fixed.
The noise
Vercel installs the workspace root (
npm install --prefix=.., since rootpackage.jsonhasworkspaces: ["website"]), which fires the rootpostinstall. But/scriptsis vercelignored, so:|| trueswallows the exit code but not the stack. It is harmless today, and it is exactly the kind of expected-looking stack trace that a real failure hides behind later.The fix
Check the file exists before running it.
node -erather than[ -f ... ] &&because npm runs lifecycle scripts throughcmd.exeon Windows, where the POSIX test builtin does not exist.Install can still never fail
That was the point of
|| true, and it is preserved two ways:--softalready makesinstall-skills.mjsexit 0 on every handled path (process.exit(soft ? 0 : 1)), andspawnSyncs status is ignored, so a hard throw inside the script cannot failnpm install -g rolestereither.Verified both paths
The real proof is the build log on merge: this PR merging to
maintriggers a production deploy, and that log should no longer containMODULE_NOT_FOUND. Checking after merge.🔧 Changed
postinstallto check forscripts/install-skills.mjsbefore running it.node -eandspawnSyncfor Windows compatibility while preserving inherited output and--softbehavior.🐛 Fixed
Prevents
MODULE_NOT_FOUNDstack traces during Vercel builds where/scriptsis absent.Keeps installs successful and silent when the installer script is unavailable.
Verify that installer spawn failures still preserve the previous non-failing
postinstallbehavior.