Skip to content

Conversation

@Divya9877
Copy link

Summary

Adds an error message for ERR_AMBIGUOUS_MODULE_SYNTAX, which is used when a file mixes CommonJS and ES Module syntax.

Changes

  • Registered ERR_AMBIGUOUS_MODULE_SYNTAX in lib/internal/errors.js with a clear explanatory message.

Why

This improves developer experience by explaining that the file mixes CommonJS (require, module.exports) with ES Module features (import, export, top-level await) and suggests using a single module system consistently.

@nodejs-github-bot nodejs-github-bot added errors Issues and PRs related to JavaScript errors originated in Node.js core. needs-ci PRs that need a full CI run. labels Dec 5, 2025
@Divya9877
Copy link
Author

Hi maintainers 👋,

This PR adds a test case for the new ERR_AMBIGUOUS_MODULE_SYNTAX error.

🔹 What I added

A new test at:
test/es-module/test-ambiguous-module-syntax.js

A new fixture at:
test/fixtures/es-modules/ambiguous-mixed-syntax.js

🔹 What the test does

Uses the mixed-syntax fixture to simulate ambiguous ESM/CJS usage.

Runs the module through Node.

Asserts that Node throws the expected error code:
ERR_AMBIGUOUS_MODULE_SYNTAX.

Ensures the new error message is correctly triggered and validated.

@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.52%. Comparing base (c6316f9) to head (4b35ee1).
⚠️ Report is 562 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #60968      +/-   ##
==========================================
+ Coverage   88.45%   88.52%   +0.06%     
==========================================
  Files         703      703              
  Lines      207546   208437     +891     
  Branches    40011    40200     +189     
==========================================
+ Hits       183591   184524     +933     
+ Misses      15949    15903      -46     
- Partials     8006     8010       +4     
Files with missing lines Coverage Δ
lib/internal/errors.js 97.52% <100.00%> (+<0.01%) ⬆️

... and 268 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aduh95
Copy link
Contributor

aduh95 commented Dec 10, 2025

Tests are not passing, and the linked issue was closed as resolved. Closing for now, thanks for the PR.

@aduh95 aduh95 closed this Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

errors Issues and PRs related to JavaScript errors originated in Node.js core. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants