Skip to content

Commit

Permalink
ES Module loading with abolute path fails on Windows unless it's conv…
Browse files Browse the repository at this point in the history
…erted to URL

nodejs/node#31710
  • Loading branch information
eliot-akira committed Jul 24, 2023
1 parent 0179c9f commit 103cadc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions config/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require('path')
const fs = require('fs')
const url = require('url')

async function createConfig({ commandName, args }) {

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 103cadc

Please sign in to comment.