admin管理员组文章数量:1336632
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?
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?
Share Improve this question edited Mar 17, 2023 at 23:48 Mike asked Mar 28, 2020 at 16:34 MikeMike 14.6k32 gold badges120 silver badges177 bronze badges1 Answer
Reset to default 6Try using:
import mysqlPromise from "mysql2/promise.js";
本文标签: javascriptCan39t import quotmysql2promisequot into ES module (MJS) on Nodejs 1314Stack Overflow
版权声明:本文标题:javascript - Can't import "mysql2promise" into ES module (MJS) on Node.js 1314 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742412792a2470124.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论