Nnodejs

nodejs/import-assertions-to-attributes

Replace `assert` import attribute to the `with` ECMAScript import attribute.

transformationmigration
Public
437 executions
Run locally
npx codemod @nodejs/import-assertions-to-attributes
Documentation

Import Assertions to Attributes

This recipe converts import assertions (assert syntax) to the standardized import attributes (with syntax). It modifies code like:

ts

Usage

Run this codemod with:

sh

When is it useful?

The import assertions syntax is being deprecated in favor of the standardized import attributes syntax. This codemod helps transition existing codebases to the new syntax, ensuring compatibility with future versions of Node.js.

Node.js drop support of import assertions in favor of import attributes in version 22.0.0
But the support for import attributes was added in Node.js version 18.20.0

Ready to contribute?

Build your own codemod and share it with the community.