This recipe converts import assertions (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nodejs/userland-migrations/llms.txt
Use this file to discover all available pages before exploring further.
assert syntax) to the standardized import attributes (with syntax) for importing JSON and other module types.
Background
Node.js dropped support for import assertions in favor of import attributes in version 22.0.0. The new syntax useswith instead of assert to align with the ECMAScript standard.
Import attributes were added in Node.js version 18.20.0.
Usage
Run this codemod with:Before/After
What It Does
- Replaces
assert { type: 'json' }withwith { type: 'json' } - Updates both static and dynamic imports
- Preserves import path and other syntax
When to Use This
Use this codemod when:- Upgrading to Node.js 22 or later
- Your codebase uses import assertions for JSON modules
- You want to adopt the standardized ECMAScript syntax