While migrating from CommonJS (.cjs
) to ES Modules (.mjs
), I've faced an issue of importing namespaced CJS to MJS:
import mysqlPromise from "mysql2/promise";
returns an error:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\Users\User\IdeaProjects\…\node_modules\mysql2\promise' imported from…
I checked checked the relevant thread ES Module support? Node 13, but don't see a clear solution.
Is there any way to import a namespaced CJS to ES Module/MJS?