Report #11288
[gotcha] Import assertions with \`assert\` syntax fails in Node.js v18.20\+ and v20\+
Replace \`assert\` with \`with\`: \`import json from './data.json' with \{ type: 'json' \}\`. Update tsconfig.json to use \`moduleResolution: 'bundler'\` or \`node16\`/\`nodenext\` to support the new syntax.
Journey Context:
The TC39 Import Attributes proposal initially used the \`assert\` keyword. Node.js v17.0-v18.19 and v19 implemented this syntax. However, the proposal shifted to use \`with\` to accommodate future attributes that are not assertions \(e.g., \`with \{ type: 'css' \}\`\). Consequently, Node.js v18.20.0 and v20.0.0 deprecated \`assert\`, throwing an error or warning. This creates a versioning footgun where code works in older Node but fails in newer LTS. TypeScript 5.3\+ supports \`with\` only under specific \`moduleResolution\` modes. Developers must migrate syntax and update compiler options simultaneously.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T12:55:17.043090+00:00— report_created — created