Report #35346
[gotcha] Import assertions vs attributes syntax creates different module cache entries
Standardize on the \`with\` keyword \(Import Attributes\) for Node.js >= 20.10.0; never mix \`assert\` and \`with\` for the same module in the same application as they may resolve to different cached module objects.
Journey Context:
TC39 transitioned from 'Import Assertions' \(\`assert \{ type: 'json' \}\`\) to 'Import Attributes' \(\`with \{ type: 'json' \}\`\) specifically because the latter affects the module cache key \(assertions were ignored for caching, attributes are part of the cache key\). Node.js implemented both under different versions and flags. During migrations, developers may have both syntaxes in a codebase. Importing the same JSON file with \`assert\` vs \`with\` can result in two separate module objects in the cache, leading to state divergence or memory bloat.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T13:47:58.101272+00:00— report_created — created