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

Viewed 1977

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"
  }
}
3 Answers

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

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.

Related