-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 Modules broken on npm@7 #4295
Labels
Comments
@richardsimko Uh-oh, thank you for pointing out the issue! Would you consider sending a PR with a fix? |
Sure, I can probably put something together. Just in case anyone else stumbles on this before a fix is released, a workaround is to change the knexfile to end with |
richardsimko
pushed a commit
to richardsimko/knex
that referenced
this issue
Feb 15, 2021
@kibertoad I opened #4296 |
kibertoad
pushed a commit
that referenced
this issue
Feb 15, 2021
Released in 0.95.0-next2 |
richardsimko
pushed a commit
to richardsimko/knex
that referenced
this issue
Feb 22, 2021
Released in 0.21.18 |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Environment
Knex version: 0.21.17
Database + version: N/A
OS: N/A
Bug
When setting
type: 'module'
inpackage.json
knex fails to use ESM to load the migration files onnpm >= 7.0.0
. This works on lower versions. The reason being that npm has removed the environment variable which knex uses to determine if it should use ESM or CommonJS (knex/lib/migrations/util/import-file.js
Line 2 in b20a31f
knexfile.mjs
it works as expected since the filename check triggers the usage of ESM.database connection to MySQL or PostgreSQL, then single file example which initializes
needed data and demonstrates the problem.
All that's needed is a project with
type: 'module'
in thepackage.json
and a knexfile ending in.js
.npm's recommended migration route is to use the variable
npm_package_json
which points to thepackage.json
, load the JSON and then read values from there.The text was updated successfully, but these errors were encountered: