From 7785eb5737ea94e96cd4ef1e1a011a66e934aa48 Mon Sep 17 00:00:00 2001 From: Chen-538 Date: Fri, 22 May 2026 11:13:48 +0800 Subject: [PATCH] fix(plugins): convert plugin path to file:// URL for ESM import on Windows Dynamic `import(indexPath)` failed on Windows with `ERR_UNSUPPORTED_ESM_URL_SCHEME` because Node's ESM loader treats the drive letter (`c:`) as a URL protocol. POSIX absolute paths happened to work, masking the issue. Use `pathToFileURL(indexPath).href` so the loader receives a valid `file://` URL on all platforms. Behavior on POSIX is unchanged. Co-Authored-By: Claude Opus 4.7 --- lib/plugins.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/plugins.js b/lib/plugins.js index 0a8f2bd..c8416c3 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -60,7 +60,7 @@ import { EventEmitter } from 'events'; import fs from 'fs'; import path from 'path'; -import { fileURLToPath } from 'url'; +import { fileURLToPath, pathToFileURL } from 'url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const ROOT_DIR = path.join(__dirname, '..'); @@ -155,7 +155,7 @@ export async function loadPlugins(app, ctx) { } try { - const mod = await import(indexPath); + const mod = await import(pathToFileURL(indexPath).href); const register = mod.default || mod.register; if (typeof register !== 'function') { ctx.log('warn', `plugin "${name}" does not export a register function, skipping`);