From 22e0ee89c27ba49fdf92c7477e8d9188cc121113 Mon Sep 17 00:00:00 2001 From: Mike Clark Date: Sun, 19 Nov 2023 13:04:34 +0000 Subject: [PATCH] fix: file URL when importing migrations so ESM will work on windows closes #201 closes #203 --- lib/load-migrations.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/load-migrations.js b/lib/load-migrations.js index 64db324..004d1f3 100644 --- a/lib/load-migrations.js +++ b/lib/load-migrations.js @@ -2,6 +2,7 @@ const path = require('path') const fs = require('fs').promises +const url = require('node:url') const Migration = require('./migration') module.exports = loadMigrationsIntoSet @@ -45,7 +46,7 @@ function loadMigrationsIntoSet (options, fn) { mod = require(filepath) } catch (e) { if (e.code === 'ERR_REQUIRE_ESM') { - mod = await import(filepath) + mod = await import(url.pathToFileURL(filepath)) } else { return fn(e) }