From 5fa566c09a370e82b55dfbec8797f064db051026 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 6 Nov 2024 11:16:45 +0000 Subject: [PATCH] fix(kit): convert module path to file url before reading meta --- packages/kit/src/module/install.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/kit/src/module/install.ts b/packages/kit/src/module/install.ts index 22101dfdbf..9399e0e346 100644 --- a/packages/kit/src/module/install.ts +++ b/packages/kit/src/module/install.ts @@ -84,13 +84,13 @@ export async function loadNuxtModuleInstance (nuxtModule: string | NuxtModule, n try { const resolved = resolveAlias(path, nuxt.options.alias) const src = isAbsolute(resolved) - ? await resolvePath(resolved, { cwd: parentURL, fallbackToOriginal: false, extensions: nuxt.options.extensions }) + ? pathToFileURL(await resolvePath(resolved, { cwd: parentURL, fallbackToOriginal: false, extensions: nuxt.options.extensions })).href : await resolveModule(resolved, { url: pathToFileURL(parentURL.replace(/\/node_modules\/?$/, '')), extensions: nuxt.options.extensions }) nuxtModule = await jiti.import(src, { default: true }) as NuxtModule // nuxt-module-builder generates a module.json with metadata including the version - const moduleMetadataPath = join(dirname(src), 'module.json') + const moduleMetadataPath = new URL('module.json', src) if (existsSync(moduleMetadataPath)) { buildTimeModuleMeta = JSON.parse(await fsp.readFile(moduleMetadataPath, 'utf-8')) }