N
Nuxt3mo ago
Robson

.nuxt/eslint.config.mjs not available in CI

When I install my project in Github actions (npm ci) and want to run npm run lint with @nuxt/eslint it fails because .nuxt/eslint.config.mjs is not available. What am I overlooking? Do I need to build the project to lint it?
3 Replies
kapa.ai
kapa.ai3mo ago
Hi @Robson. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The issue you're encountering is because the @nuxt/eslint module generates the .nuxt/eslint.config.mjs file at runtime (when the Nuxt app starts). This file is required for linting, as the ESLint config imports from it by default. In CI environments, this file won't exist unless you run a Nuxt build or dev command first, since npm ci alone does not trigger Nuxt to generate .nuxt files. What you are overlooking:
You need to generate the .nuxt directory (and thus .nuxt/eslint.config.mjs) before running your lint command in CI. This can be done by running npx nuxi prepare (or npx nuxi build or npx nuxi dev, but prepare is the lightest and fastest) before npm run lint. You do not need to fully build the project, but you do need to run a Nuxt command that generates the .nuxt directory. Example for your GitHub Actions workflow:
- run: npx nuxi prepare
- run: npm run lint
- run: npx nuxi prepare
- run: npm run lint
This step ensures .nuxt/eslint.config.mjs is available for ESLint to use. References:
- The ESLint module generates a project-aware config and expects .nuxt/eslint.config.mjs to exist, as shown in the manual setup instructions and Nuxt code style guide. - The config file is generated when the Nuxt app starts, not during a plain npm ci install. If you want to avoid this dependency, you could consider customizing your ESLint config to not rely on the generated file, but the recommended and simplest approach is to run nuxi prepare before linting. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3mo ago
<@733692382268227605> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Robson
RobsonOP3mo ago
Great feedback, npx nuxi prepare was what I needed.

Did you find this page helpful?