Skip to content

fix(core): improve nx wrapper error message for malformed nx.json#34736

Merged
FrozenPandaz merged 2 commits intomasterfrom
fix/nxw-improve-nx-json-parse-error-message
Mar 10, 2026
Merged

fix(core): improve nx wrapper error message for malformed nx.json#34736
FrozenPandaz merged 2 commits intomasterfrom
fix/nxw-improve-nx-json-parse-error-message

Conversation

@MaxKless
Copy link
Copy Markdown
Contributor

@MaxKless MaxKless commented Mar 6, 2026

Current Behavior

When nx.json exists but contains a syntax error (e.g. invalid JSON), the nx wrapper shows:

[NX]: The "nx.json" file is required when running the nx wrapper.

This is misleading because the file exists — it's just malformed.

Expected Behavior

The nx wrapper now distinguishes between a missing nx.json and a malformed one:

  • Missing file: [NX]: The "nx.json" file is required when running the nx wrapper.
  • Parse error: [NX]: Failed to parse "nx.json": <actual error>. See ...

The existence check is done upfront before attempting to parse, so the catch block only handles parse errors.

When nx.json exists but contains a syntax error, the nx wrapper now
shows the actual parse error instead of the misleading message that
nx.json is missing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@MaxKless MaxKless requested a review from a team as a code owner March 6, 2026 12:09
@MaxKless MaxKless requested a review from leosvelperez March 6, 2026 12:09
@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 6, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 95dd58b
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69aebe8933d6430008c278f0
😎 Deploy Preview https://deploy-preview-34736--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
Copy Markdown

netlify Bot commented Mar 6, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 95dd58b
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69aebe8914484000089120bf
😎 Deploy Preview https://deploy-preview-34736--nx-docs.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.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Mar 6, 2026

View your CI Pipeline Execution ↗ for commit 95dd58b

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 49m 40s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3m 28s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 7s 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-09 13:29:48 UTC

Comment thread packages/nx/src/command-line/init/implementation/dot-nx/nxw.ts Outdated
Comment thread packages/nx/src/command-line/init/implementation/dot-nx/nxw.ts Outdated
Move the missing-file vs parse-error distinction into the catch block
by checking the error code instead of using a separate existsSync call.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@MaxKless MaxKless requested a review from FrozenPandaz March 9, 2026 12:36
@FrozenPandaz FrozenPandaz merged commit 3945a74 into master Mar 10, 2026
24 checks passed
@FrozenPandaz FrozenPandaz deleted the fix/nxw-improve-nx-json-parse-error-message branch March 10, 2026 19:44
@github-actions
Copy link
Copy Markdown
Contributor

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants