无法加载插件@ typescript-eslint:找不到模块'eslint-plugin- @ typescript-eslint' [英] Failed to load plugin @typescript-eslint: Cannot find module 'eslint-plugin-@typescript-eslint'

查看:9662
本文介绍了无法加载插件@ typescript-eslint:找不到模块'eslint-plugin- @ typescript-eslint'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将项目从tslint重新配置为eslint.我可以手动运行eslint,但是webpack无法运行,并显示以下错误消息:

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'

我排除了错误的.eslintrc.js并缺少依赖项,因为当我手动运行它时它可以工作./node_modules/eslint/bin/eslint.js ./--ext .ts,.tsx --config ./. eslintrc.js

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

我不确定这是否是eslint-loader的上游问题.

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
  }
};

我的package.json

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

推荐答案

您需要升级eslint版本,错误中您会看到错误的前缀eslint-plugin-,这是由于eslint/lib/config/plugins.js中的某些const导致的,该常量随后已被删除.版本.

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.

这篇关于无法加载插件@ typescript-eslint:找不到模块'eslint-plugin- @ typescript-eslint'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆