Import assertions (assert { type: "json" }) were replaced in the JavaScript standard by import attributes (with { type: "json" }). Per the TypeScript 5.8 page, Node.js 22 no longer accepts assert, and under module: "nodenext" TypeScript reports it as TS2880.
The fix is one word, and the rest of the import stays as it is.
At a glance
| Code | TS2880 |
|---|---|
| Message | Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. |
| TypeScript's category | error |
| Listed under | Modules and imports |
| Depends on | module |
| In .js files | Reported when the file is checked: checkJs in jsconfig.json, or // @ts-check at the top of the file |
The message is TypeScript's own text from its diagnostic messages file (Apache-2.0).
What it looks like
main.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026:
main.js(2,36): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3.
main.js(2,36): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3.
main.js(2,36): error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'. checked 21 October 2026
import config from "./config.json" assert { type: "json" };error TS2880: Import assertions have been replaced by import attributes. Use 'with' instead of 'assert'.
export const port = config.port;jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["**/*.js"]
} What causes it
- Code written for Node.js 16 to 20, or copied from older documentation, that still says
assert.
How to fix it
Write with instead of assert
import config from "./config.json" with { type: "json" }; is accepted by current Node.js versions and by TypeScript under every module setting that allows attributes.
main.js TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026:
No errors. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3.
No errors. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3.
No errors. checked 21 October 2026
import config from "./config.json" with { type: "json" };
export const port = config.port;jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["**/*.js"]
} Gotchas
- With
module: "esnext"or"preserve", TypeScript 5.9 still acceptsassert, so the error appears when a project moves tonodenext. - The same JSON import without any attribute is TS1543 under
nodenext.
Sources
- TypeScript 5.8 release notes · TypeScript handbook
- Modules: import attributes · Node.js documentation
- diagnosticMessages.json (TypeScript 5.9.3) · TypeScript on GitHub
Last reviewed 21 October 2026.