nuxt/eslint

Cannot find module '[...]/.nuxt/eslint.config.mjs'

Closed this issue · 3 comments

Environment

- Operating System: Linux
- Node Version:     v21.7.3
- Nuxt Version:     3.11.2
- CLI Version:      3.11.1
- Nitro Version:    2.9.6
- Package Manager:  npm@10.7.0
- Builder:          -
- User Config:      devtools, build, plugins, modules, vite, basicAuth
- Runtime Modules:  @kgierke/nuxt-basic-auth@1.5.0, ()
- Build Modules:    -

Package

@nuxt/eslint

Reproduction

After running npm install --save-dev @nuxt/eslint eslint, adding @nuxt/eslint to modules in nuxt.config.ts and creating a eslint.config.mjs file in the project root as per https://eslint.nuxt.com/packages/module, running npx eslint . gives the following error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '<PATH>/.nuxt/eslint.config.mjs' imported from <PATH>/eslint.config.mjs

The import looks like this:
import withNuxt from './.nuxt/eslint.config.mjs'

...and there is indeed no eslint.config.mjs file under the .nuxt directory.

Describe the bug

There is no .nuxt/eslint.config.mjs file

Additional context

No response

Logs

No response

Did you started the nuxt server once? Or try nuxi prepare

We temporarily closed this due to the lack of enough information. We could not identify whether it was a bug or a userland misconfiguration with the given info.
Please provide a minimal reproduction to reopen the issue.
Thanks.

Why reproduction is required

For anyone else struggling with this: It seem that the issue is related to Vuetify. If I install first eslint and _then_Vuetify, then running npx nuxi prepare will create the file. But if I have the recommended Vuetify setup in nuxt.config.ts (see below) it does nothing (and nuxi module add eslint throws a bunch of errors saying: Casting "BlockStatement" is not supported).

This is the recommended way to enable Vuetify, that seems to prevent eslint installation:

  modules: [
    (_options, nuxt) => {
      nuxt.hooks.hook('vite:extendConfig', (config) => {
        // @ts-expect-error
        config.plugins.push(vuetify({ autoImport: true }))
      })
    },
  ],

A workaround is to remove the whole Vuetify block from the config, run nuxi prepare, and then re-add Vuetify.