Failed to load plugin @typescript-eslint: Cannot find module 'eslint-plugin-@typescript-eslint'
Asked Answered
B

2

50

I am reconfiguring my project from tslint to eslint. I can run eslint manually, but webpack fails to run with this error message:

Module build failed (from /path/node_modules/eslint-loader/index.js):
Error: Failed to load plugin @typescript-eslint: Cannot find module 'eslint-plugin-@typescript-eslint'

I have ruled out bad .eslintrc.js and missing dependencies since it works when I run it manually ./node_modules/eslint/bin/eslint.js ./ --ext .ts,.tsx --config ./.eslintrc.js

I'm not sure if this is an upstream issue with eslint-loader.

module.exports = {
  parser: "@typescript-eslint/parser",
  plugins: ["@typescript-eslint"],
  extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:react/recommended", "plugin:jest/recommended", "prettier", "prettier/@typescript-eslint"],
  rules: {
    "react/prop-types": false
  },
  parserOptions: {
    ecmaVersion: 6,
    project: "./tsconfig.json",
    sourceType: "module"
  },
  settings: {
    react: {
      version: "detect"
    },
    linkComponents: [
      {"name": "Link", "linkAttribute": "href"}
    ]
  },
  env: {
    browser: true
  }
};

My package.json

{
    "dependencies": {
        "@emotion/core": "10.0.6",
        "facepaint": "1.2.1",
        "react": "16.7.0",
        "react-dom": "16.7.0",
        "react-redux": "6.0.0",
        "redux": "4.0.1",
        "tslib": "1.9.3"
    },
    "devDependencies": {
        "@types/node": "10.12.21",
        "@types/react": "16.8.1",
        "@types/react-dom": "16.0.11",
        "@types/react-redux": "7.0.1",
        "@typescript-eslint/eslint-plugin": "1.2.0",
        "eslint": "5.13.0",
        "eslint-config-prettier": "4.0.0",
        "eslint-plugin-jest": "22.2.2",
        "eslint-plugin-react": "7.12.4",
        "tsconfig-paths-webpack-plugin": "3.2.0",
        "typescript": "3.2.1"
    }
}
Billingsley answered 4/2, 2019 at 11:18 Comment(2)
Did you try npm i eslint? I solved the same issue by updating eslint.Refuse
Yeah, my dependencies are up to date.Billingsley
H
13

You need to upgrade your eslint version, in the error you can see a bad prefix eslint-plugin- due to some const in eslint/lib/config/plugins.js which was removed in later versions.

Headlight answered 20/2, 2019 at 11:22 Comment(5)
I use eslint-loader. Just figured out that it uses an older version of eslint, unless you specify the path to eslint using config options. I was able to fix it, but ran into other issues. Looks like eslint-loader does not support the newest version of eslint.Billingsley
@ThilakRao did you try to update the eslint-loader correspondently?Headlight
@Headlight Yeah, I'm on the latest version of eslint-loader (v2.1.2), but did not fix my issue.Billingsley
I'm on "eslint": "^6.1.0", and "eslint-loader": "^2.0.0", and still same errorPeaceable
for upgrading Eslint I just run npm i -G eslintWordbook
L
2

updating ESlint fixed it in my case

npm i eslint
Laudable answered 6/11, 2023 at 10:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.