TS2821
Import assertions are only supported when the
--moduleoption is set toesnextornodenext.
Broken Code ❌
import accounts from './accounts.json' assert { type: 'json' };
console.log(accounts);{
"compilerOptions": {
"module": "node16"
}
}Fixed Code ✔️
Make sure that "module" in your tsconfig.json is set to esnext or nodenext before using an import assertion.
{
"compilerOptions": {
"module": "nodenext"
}
}