Skip to content

Commit 1d2bad4

Browse files
MikesGlitchwesleytodd
authored andcommitted
fix: file URL when importing migrations so ESM will work on windows
closes #201 closes #202
1 parent 1ed0f4c commit 1d2bad4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/load-migrations.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const path = require('path')
44
const fs = require('fs').promises
5+
const url = require('node:url')
56
const Migration = require('./migration')
67

78
module.exports = loadMigrationsIntoSet
@@ -45,7 +46,7 @@ function loadMigrationsIntoSet (options, fn) {
4546
mod = require(filepath)
4647
} catch (e) {
4748
if (e.code === 'ERR_REQUIRE_ESM') {
48-
mod = await import(filepath)
49+
mod = await import(url.pathToFileURL(filepath))
4950
} else {
5051
return fn(e)
5152
}

0 commit comments

Comments
 (0)