Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

es module support? Node 13 #1093

Closed
zsolt-dev opened this issue Dec 31, 2019 · 4 comments · Fixed by #1100
Closed

es module support? Node 13 #1093

zsolt-dev opened this issue Dec 31, 2019 · 4 comments · Fixed by #1100

Comments

@zsolt-dev
Copy link

Hi,

First, thank you for maintaining this great library.

I would like to use node 13 without babel.

I have a file index.mjs in which I am trying to do:

import mysql from 'mysql2/promise';

and I am getting this error:

(node:27011) ExperimentalWarning: The ESM module loader is experimental.
internal/modules/esm/default_resolve.js:96
  let url = moduleWrapResolve(specifier, parentURL);
            ^

Error: Cannot find module /Users/zsoltszabo/coding/media-app/node_modules/mysql2/promise imported from /Users/zsoltszabo/coding/media-app/server/db/reset/index.mjs
    at Loader.resolve [as _resolve] (internal/modules/esm/default_resolve.js:96:13)
    at Loader.resolve (internal/modules/esm/loader.js:73:33)
    at Loader.getModuleJob (internal/modules/esm/loader.js:147:40)
    at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:41:40)
    at link (internal/modules/esm/module_job.js:40:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}
@joeyhub
Copy link

joeyhub commented Dec 31, 2019

Any luck with the full path IE import mysql from 'mysql2/promise.js'; ?

I also put "type": "module", in package.json.

@sidorares
Copy link
Owner

@zsolt-dev can you try adding https://nodejs.org/api/esm.html#esm_package_exports to package.json? If that works happy to accept pr

@pubmikeb
Copy link

@sidorares, I'm currently facing an issue with importing mysql2/promise to ES module/MJS, but it doesn't work. Could you, please, give some hint how to cope with such issue?

Thanks.

@jaydenseric
Copy link

For the benefit of people tracking this issue, I've left some comments on the topic here: #1100 (comment) .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants