Skip to content

fix(core): suppress postinstall error output when nx is not yet built#34986

Merged
FrozenPandaz merged 1 commit intomasterfrom
fix-postinstall2
Mar 24, 2026
Merged

fix(core): suppress postinstall error output when nx is not yet built#34986
FrozenPandaz merged 1 commit intomasterfrom
fix-postinstall2

Conversation

@FrozenPandaz
Copy link
Collaborator

Current Behavior

The postinstall script in packages/nx/package.json runs node ./dist/bin/post-install which prints noisy error logs to stderr when the dist directory hasn't been built yet (e.g. during pnpm install in the workspace). The script already exits cleanly via || exit 0, but the error output is confusing.

Expected Behavior

The postinstall script silently succeeds when the dist directory doesn't exist, without printing error logs to the console.

Related Issue(s)

N/A - minor DX improvement

@FrozenPandaz FrozenPandaz requested a review from a team as a code owner March 24, 2026 15:19
@netlify
Copy link

netlify bot commented Mar 24, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 170c9fa
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69c2bda94d51070008ee0438
😎 Deploy Preview https://deploy-preview-34986--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Mar 24, 2026

Deploy Preview for nx-docs failed. Why did it fail? →

Name Link
🔨 Latest commit 170c9fa
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69c2bda9a98cf00008ece504

@nx-cloud
Copy link
Contributor

nx-cloud bot commented Mar 24, 2026

View your CI Pipeline Execution ↗ for commit 170c9fa

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 44m 50s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 9s View ↗
nx-cloud record -- pnpm nx conformance:check ✅ Succeeded 8s View ↗
nx build workspace-plugin ✅ Succeeded 1m 58s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-24 17:28:13 UTC

},
"scripts": {
"postinstall": "node ./dist/bin/post-install || exit 0"
"postinstall": "node ./dist/bin/post-install 2>/dev/null || exit 0"
Copy link
Contributor

Choose a reason for hiding this comment

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

This change breaks cross-platform compatibility. The 2>/dev/null syntax only works on Unix/Linux/macOS systems and will fail on Windows where /dev/null doesn't exist. Windows uses NUL instead.

This will cause the postinstall script to fail for Windows users. Consider using a cross-platform solution:

"postinstall": "node -e \"try{require('./dist/bin/post-install')}catch{}\""

Or use a package like cross-env or write the suppression logic in the post-install script itself rather than in the shell command.

Suggested change
"postinstall": "node ./dist/bin/post-install 2>/dev/null || exit 0"
"postinstall": "node -e \"try{require('./dist/bin/post-install')}catch{}\""

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

The postinstall script runs `node ./dist/bin/post-install` which fails
with noisy error logs when the dist directory hasn't been built yet
(e.g. in the pnpm workspace). Redirect stderr to /dev/null to hide
these harmless errors.
@FrozenPandaz FrozenPandaz enabled auto-merge (squash) March 24, 2026 17:36
@FrozenPandaz FrozenPandaz merged commit ac20315 into master Mar 24, 2026
20 of 24 checks passed
@FrozenPandaz FrozenPandaz deleted the fix-postinstall2 branch March 24, 2026 17:43
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.

2 participants