diff --git a/packages/nuxt/src/core/app.ts b/packages/nuxt/src/core/app.ts index 2bf753c58c..95deb12f17 100644 --- a/packages/nuxt/src/core/app.ts +++ b/packages/nuxt/src/core/app.ts @@ -1,5 +1,5 @@ import { promises as fsp } from 'node:fs' -import { dirname, resolve } from 'pathe' +import { dirname, resolve, join } from 'pathe' import defu from 'defu' import type { Nuxt, NuxtApp, NuxtPlugin, NuxtTemplate, ResolvedNuxtTemplate } from '@nuxt/schema' import { findPath, resolveFiles, normalizePlugin, normalizeTemplate, compileTemplate, templateUtils, tryResolveModule, resolvePath, resolveAlias } from '@nuxt/kit' @@ -74,7 +74,9 @@ export async function resolveApp (nuxt: Nuxt, app: NuxtApp) { // Resolve error component if (!app.errorComponent) { - app.errorComponent = (await findPath(['~/error'])) || resolve(nuxt.options.appDir, 'components/nuxt-error-page.vue') + app.errorComponent = (await findPath( + nuxt.options._layers.map(layer => join(layer.config.srcDir, 'error')) + )) ?? resolve(nuxt.options.appDir, 'components/nuxt-error-page.vue') } // Resolve layouts/ from all config layers