Skip to content

🐛 fix(build): guard root postinstall so it stops printing a MODULE_NOT_FOUND stack#19

Merged
scttbnsn merged 1 commit into
mainfrom
fix/postinstall-guard
Jul 9, 2026
Merged

🐛 fix(build): guard root postinstall so it stops printing a MODULE_NOT_FOUND stack#19
scttbnsn merged 1 commit into
mainfrom
fix/postinstall-guard

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

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 root package.json has workspaces: ["website"]), which fires the root postinstall. But /scripts is vercelignored, so:

> rolester@0.5.2 postinstall
> node scripts/install-skills.mjs --soft || true

Error: Cannot find module `/vercel/path0/scripts/install-skills.mjs`
    at Module._resolveFilename ...
  code: `MODULE_NOT_FOUND`

|| true swallows 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 -e "const f='scripts/install-skills.mjs'; if (require('fs').existsSync(f)) require('child_process').spawnSync(process.execPath,[f,'--soft'],{stdio:'inherit'})"

node -e rather than [ -f ... ] && because npm runs lifecycle scripts through cmd.exe on 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: --soft already makes install-skills.mjs exit 0 on every handled path (process.exit(soft ? 0 : 1)), and spawnSyncs status is ignored, so a hard throw inside the script cannot fail npm install -g rolester either.

Verified both paths

scripts/ present scripts/ absent (Vercel)
old runs, exit 0 2 stack lines, exit 0
new runs, exit 0 silent, exit 0

The real proof is the build log on merge: this PR merging to main triggers a production deploy, and that log should no longer contain MODULE_NOT_FOUND. Checking after merge.

🔧 Changed

  • Updated postinstall to check for scripts/install-skills.mjs before running it.
  • Uses node -e and spawnSync for Windows compatibility while preserving inherited output and --soft behavior.

🐛 Fixed

  • Prevents MODULE_NOT_FOUND stack traces during Vercel builds where /scripts is absent.

  • Keeps installs successful and silent when the installer script is unavailable.

  • Verify that installer spawn failures still preserve the previous non-failing postinstall behavior.

…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).
@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rolester-website Ready Ready Preview, Comment Jul 9, 2026 10:53pm

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 072a2fc7-0e98-4af7-83d6-6fcf74d3f874

📥 Commits

Reviewing files that changed from the base of the PR and between 0236e3e and 9468700.

📒 Files selected for processing (1)
  • package.json

📝 Walkthrough

Walkthrough

Updated the postinstall script to check whether scripts/install-skills.mjs exists before running it. When present, the script invokes it with Node, the --soft argument, and inherited standard I/O. The previous unconditional execution and explicit || true fallback were removed.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/postinstall-guard

Comment @coderabbitai help to get the list of available commands.

@biggest-littlest biggest-littlest left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ALARGECOMPANY left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good cleanup. Silent build logs make real failures visible.

@scttbnsn scttbnsn merged commit a62535e into main Jul 9, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants