diff --git a/packages/kit/src/module/install.ts b/packages/kit/src/module/install.ts index 9bcabb9f84..1149fc9d94 100644 --- a/packages/kit/src/module/install.ts +++ b/packages/kit/src/module/install.ts @@ -84,7 +84,7 @@ export async function loadNuxtModuleInstance (nuxtModule: string | NuxtModule, n for (const parentURL of nuxt.options.modulesDir) { for (const path of paths) { try { - const src = jiti.esmResolve(path, { parentURL }) + const src = jiti.esmResolve(path, { parentURL: parentURL.replace(/\/node_modules\/?$/, '') }) nuxtModule = await jiti.import(src) as NuxtModule // nuxt-module-builder generates a module.json with metadata including the version diff --git a/packages/vite/src/css.ts b/packages/vite/src/css.ts index 4a26447584..c3f6871422 100644 --- a/packages/vite/src/css.ts +++ b/packages/vite/src/css.ts @@ -29,7 +29,7 @@ export async function resolveCSSOptions (nuxt: Nuxt): Promise let pluginFn: ((opts: Record) => Plugin) | undefined for (const parentURL of nuxt.options.modulesDir) { - pluginFn = await jiti.import(pluginName, { parentURL, try: true }) as (opts: Record) => Plugin + pluginFn = await jiti.import(pluginName, { parentURL: parentURL.replace(/\/node_modules\/?$/, ''), try: true }) as (opts: Record) => Plugin if (typeof pluginFn === 'function') { css.postcss.plugins.push(pluginFn(pluginOptions)) break diff --git a/packages/webpack/src/utils/postcss.ts b/packages/webpack/src/utils/postcss.ts index 1548355eb0..5f6daa8d1c 100644 --- a/packages/webpack/src/utils/postcss.ts +++ b/packages/webpack/src/utils/postcss.ts @@ -51,7 +51,7 @@ export async function getPostcssConfig (nuxt: Nuxt) { let pluginFn: ((opts: Record) => Plugin) | undefined for (const parentURL of nuxt.options.modulesDir) { - pluginFn = await jiti.import(pluginName, { parentURL, try: true }) as (opts: Record) => Plugin + pluginFn = await jiti.import(pluginName, { parentURL: parentURL.replace(/\/node_modules\/?$/, ''), try: true }) as (opts: Record) => Plugin if (typeof pluginFn === 'function') { plugins.push(pluginFn(pluginOptions)) break