fix(core): suppress postinstall error output when nx is not yet built#34986
Merged
FrozenPandaz merged 1 commit intomasterfrom Mar 24, 2026
Merged
fix(core): suppress postinstall error output when nx is not yet built#34986FrozenPandaz merged 1 commit intomasterfrom
FrozenPandaz merged 1 commit intomasterfrom
Conversation
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
❌ Deploy Preview for nx-docs failed. Why did it fail? →
|
Contributor
|
View your CI Pipeline Execution ↗ for commit 170c9fa
☁️ Nx Cloud last updated this comment at |
packages/nx/package.json
Outdated
| }, | ||
| "scripts": { | ||
| "postinstall": "node ./dist/bin/post-install || exit 0" | ||
| "postinstall": "node ./dist/bin/post-install 2>/dev/null || exit 0" |
Contributor
There was a problem hiding this comment.
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
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.
eea4ebc to
170c9fa
Compare
AgentEnder
approved these changes
Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current Behavior
The
postinstallscript inpackages/nx/package.jsonrunsnode ./dist/bin/post-installwhich prints noisy error logs to stderr when thedistdirectory hasn't been built yet (e.g. duringpnpm installin 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