-
Notifications
You must be signed in to change notification settings - Fork 171
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
fix: change from require to dynamic import #893
base: main
Are you sure you want to change the base?
Conversation
Can someone please review this? I too experience this bug. |
To all participants subscribed to this PR: please try out v7.0.0-alpha.2 and report if it is still broken. |
Will test this in the following days, and provide feedback. thanks |
@rialco Do you have feedback for me? |
Hey! sorry for the delay in replying back. Tested the v7.0.0-alpha.2 that you suggested in my old repo that used the proposed fix and its still not working with this new version : |
Please test something out for me: Ah, and also try the newest version, not the v7.0.0-alpha.2. |
I updated to the latest version and tried to execute the previous line but got this:
|
Oh this is really interesting info for me 👍 Okay, last try (https://www.unpkg.com/browse/node-pg-migrate@7.4.0/bin/node-pg-migrate.mjs) |
weird getting permission denied. (just for context, I am using macos) - tried with sudo as well |
Okay, I will try to find time for this next few days |
Idea for a temp workaround So instead if just running it and assuming |
Now I get this:
|
Summary
Change the way the migrations files are being loaded in the
loadMigrations
function. Replace fromrequire
to a dynamic importawait import
in order to support ESM projects.Known issues
In a pure ESM project the node-pg-migrate module is not usable because the
loadMigrations
function usesrequire
instead ofawait import
.Current project characteristics:
"type" : "module"
tsconfig.json content:
Script used to run the migrations:
"migrate:build" : "./node_modules/.bin/node-pg-migrate -m ./dist/migrations"
Logs