Nuxt · NUXT0108

Do not import app code into server code

Report runtime imports in Nuxt server code that resolve to app code: ~/, @/, ~~/app/, @@/app/, relative paths, and layer or manifest aliases.
NUXT0108vite-doctor/nuxtarchitectureerrorSuggestion

Run this rule

pnpm nuxt doctor --rules nuxt/structure/no-app-code-in-server

Why it matters

Nuxt's import protection only rejects #app in server code. Importing an app module from server/ builds without a warning and Nitro bundles it into the server output. App code can rely on Nuxt's app auto-imports, plugins and browser APIs, which the server does not have, and it couples server code to the app's internals. Code used by both sides belongs in shared/utils/, which Nuxt auto-imports in both the app and the server.

Move code used by both the server and the app to shared/utils/. Keep code that needs the Vue app in app/.

Example

Share utilities through shared/utils

Before

// server/api/cart.get.ts
import { formatPrice } from '~/utils/format'

After

// shared/utils/format.ts
export const formatPrice = (cents: number) => (cents / 100).toFixed(2)

// server/api/cart.get.ts: auto-imported
export default defineEventHandler(() => formatPrice(1999))
Copyright © 2026