Rodrigo
Rodrigo

Reputation: 301

error - ESLint must be installed: yarn add --dev eslint

I just created a new project using

npx create-next-app@latest --ts

And when I run

npm run lint

I got the error:

next lint info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5 error - ESLint must be installed: yarn add --dev eslint

But eslint already installed!

What could be?

Steps to reproduce:

npx create-next-app@latest --ts
cd app
npm install
npm run lint

My package.json

{
  "name": "frontend",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "lint:css": "stylelint '**/*.{css,tsx}'",
    "format": "prettier '**/*' --write --ignore-unknown",
    "prepare": "husky install"
  },
  "dependencies": {
    "next": "11.1.2",
    "react": "17.0.2",
    "react-dom": "17.0.2"
  },
  "devDependencies": {
    "@stylelint/postcss-css-in-js": "^0.37.2",
    "@types/react": "17.0.31",
    "eslint": "^8.0.1",
    "eslint-config-next": "11.1.2",
    "husky": "^7.0.4",
    "postcss-syntax": "^0.36.2",
    "prettier": "^2.4.1",
    "pretty-quick": "^3.1.1",
    "stylelint": "^14.0.0",
    "stylelint-config-standard": "^23.0.0",
    "stylelint-config-styled-components": "^0.1.1",
    "typescript": "4.4.4"
  }
}

Upvotes: 6

Views: 7564

Answers (3)

Hussam Khatib
Hussam Khatib

Reputation: 640

This was a known issue and has been fixed now.
You can upgrade nextjs v12. source

Upvotes: 4

Ahmad Bilal
Ahmad Bilal

Reputation: 101

If you still get the issue, try looking for the .eslintrc file to see if it already exists. If it does, delete it and re-run npm run lint. Doing so fixed my problem.

Upvotes: 2

Leitoop
Leitoop

Reputation: 41

This issue is related to eslint 8.0.1. Downgrade to 7.32.0.

You'll find more info in this open bug: https://github.com/vercel/next.js/issues/29961#issuecomment-945823476

Upvotes: 4

Related Questions