Search This Blog

Thursday, December 26, 2024

Error: Can only be default-imported using the 'esModuleInterop' flag

 

Recently we have faced issue with node js app with following error:


node_modules/@types/express/index"' can only be default-imported using
the 'esModuleInterop' flag

Error Line: import express from "express";

Reason we see esModuleInterop flag was not set as true and ES versions were
not compatible.

To fix this error, we have set

"esModuleInterop" : true

in tsconfig.json in the Compiler-options

Then issue was sorted.

Cheers,
Kapil

No comments:

Post a Comment

Thanks for your comment, will revert as soon as we read it.

Popular Posts