mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-14 14:50:16 +00:00
fix: Fix import error on Windows (ERR_UNSUPPORTED_ESM_URL_SCHEME) (#27519)
This commit is contained in:
@@ -218,7 +218,8 @@ export default abstract class ExternalJSExtension<M> extends Extension {
|
||||
fs.copyFileSync(file, tmpFile);
|
||||
try {
|
||||
// Do `replaceAll("\\", "/")` to prevent issues on Windows
|
||||
const mod = await import(tmpFile.replaceAll("\\", "/"));
|
||||
/* v8 ignore next */
|
||||
const mod = await import(os.platform() === "win32" ? `file:///${tmpFile.replaceAll("\\", "/")}` : tmpFile);
|
||||
return mod;
|
||||
} finally {
|
||||
fs.rmSync(tmpFile);
|
||||
|
||||
Reference in New Issue
Block a user