Skip to content
Latchkey

Nuxt auto-import name conflict / "is already declared" in CI

Nuxt auto-imports composables, components, and utilities by name. When a name collides (two files export the same symbol, or you also import it manually), the bundler sees a duplicate declaration and the build fails.

What this error means

nuxt build fails with "SyntaxError: Identifier 'useFoo' has already been declared" or a warning that two auto-imports resolve the same name, naming the conflicting files.

nuxt
SyntaxError: Identifier 'useAuth' has already been declared
  at composables/auth.ts
  (also auto-imported from composables/useAuth.ts)

Common causes

Two sources export the same auto-imported name

Two files in composables/ (or a module and a local file) both expose useAuth, so the generated imports clash.

A manual import duplicates an auto-import

You explicitly import { useAuth } for a symbol Nuxt already auto-imports, declaring it twice.

How to fix it

Rename one of the conflicting exports

  1. Find the two files the error names.
  2. Rename one composable so the auto-import names are unique.
  3. Update call sites to the new name.
composables/useAuthSession.ts
// composables/useAuthSession.ts
export const useAuthSession = () => { /* ... */ }

Remove the redundant manual import

Drop explicit imports of symbols Nuxt already auto-imports so they are declared once.

app.vue
// remove this; useAuth is auto-imported
// import { useAuth } from '~/composables/useAuth'

How to prevent it

  • Keep composable and component names unique across auto-import dirs.
  • Do not manually import symbols Nuxt auto-imports.
  • Scope or rename module-provided composables that clash with local ones.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →