diff --git a/packages/nuxt/src/app/plugins/check-if-layout-used.ts b/packages/nuxt/src/app/plugins/check-if-layout-used.ts index 2656afa8c4..9bf087d146 100644 --- a/packages/nuxt/src/app/plugins/check-if-layout-used.ts +++ b/packages/nuxt/src/app/plugins/check-if-layout-used.ts @@ -1,5 +1,6 @@ import { defineNuxtPlugin } from '../nuxt' import { onNuxtReady } from '../composables/ready' +import { useError } from '../composables/error' // @ts-expect-error virtual file import layouts from '#build/layouts' @@ -7,8 +8,10 @@ import layouts from '#build/layouts' export default defineNuxtPlugin({ name: 'nuxt:checkIfLayoutUsed', setup (nuxtApp) { + const error = useError() + function checkIfLayoutUsed () { - if (!nuxtApp._isNuxtLayoutUsed && Object.keys(layouts).length > 0) { + if (!error.value && !nuxtApp._isNuxtLayoutUsed && Object.keys(layouts).length > 0) { console.warn('[nuxt] Your project has layouts but the `` component has not been used.') } }