From 103cadcb08e2bb47f83092bdbcc7ab23094aadd7 Mon Sep 17 00:00:00 2001 From: eliot-akira Date: Mon, 24 Jul 2023 19:57:29 +0200 Subject: [PATCH] ES Module loading with abolute path fails on Windows unless it's converted to URL https://github.com/nodejs/node/issues/31710 --- config/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/config/index.js b/config/index.js index 221c9b9..a56789e 100644 --- a/config/index.js +++ b/config/index.js @@ -1,5 +1,6 @@ const path = require('path') const fs = require('fs') +const url = require('url') async function createConfig({ commandName, args }) { @@ -48,8 +49,14 @@ Documentation: ${require('../package.json').homepage} return } - const { default: configJson } = await import(configJsPath) - // const configJson = require(configJsPath) + /** + * ES Module loading with abolute path fails on Windows unless it's + * converted to URL: https://github.com/nodejs/node/issues/31710 + */ + const configJsPathUrl = url.pathToFileURL(configJsPath).href + + const { default: configJson } = await import(configJsPathUrl) + // const configJson = require(configJsPath) // Previously with CommonJS const packageJson = fs.existsSync(packageJsonPath) ? require(packageJsonPath)