简体   繁体   English

无法加载插件@typescript-eslint:找不到模块“eslint-plugin-@typescript-eslint”

[英]Failed to load plugin @typescript-eslint: Cannot find module 'eslint-plugin-@typescript-eslint'

I am reconfiguring my project from tslint to eslint.我正在将我的项目从 tslint 重新配置为 eslint。 I can run eslint manually, but webpack fails to run with this error message:我可以手动运行 eslint,但是 webpack 无法运行并显示以下错误消息:

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我已经排除了坏的 .eslintrc.js 和缺少的依赖项,因为它在我手动运行时可以工作 ./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.我不确定这是否是 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我的 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一些常量在更高版本中被删除。

I fixed this error by replacing all the ^ to empty in the package.json , and then npm i .我通过将package.json中的所有 ^ 替换为空来修复此错误,然后npm i

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ESLint 找不到插件“eslint-plugin-@typescript-eslint” - ESLint couldn't find the plugin "eslint-plugin-@typescript-eslint" 安装带有 Vue CLI 的 TypeScript 返回 *找不到模块 'eslint-plugin-@typescript-eslint'* - Installing TypeScript w/Vue CLI returns *Cannot find module 'eslint-plugin-@typescript-eslint'* ESLint:8.0.0 无法加载插件'@typescript-eslint' - ESLint: 8.0.0 Failed to load plugin '@typescript-eslint' ESLint 无法识别“@typescript-eslint/eslint-plugin” - ESLint is not recognizing "@typescript-eslint/eslint-plugin" ESLint 与 eslint-plugin-import 和 typescript-eslint 冲突 - ESLint conflicts with eslint-plugin-import and typescript-eslint 无法加载在 'package.json » eslint-config-react-app#overrides[0]' 中声明的解析器 '@typescript-eslint/parser':找不到模块 'typescript' - Failed to load parser '@typescript-eslint/parser' declared in 'package.json » eslint-config-react-app#overrides[0]': Cannot find module 'typescript' 使用 Prettier Eslint 时找不到模块“@typescript-eslint/parser” - Cannot find module '@typescript-eslint/parser' when using Prettier Eslint eslint 失败,无法读取配置文件:/some/path/node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended - eslint fails with Cannot read config file: /some/path/node_modules/@typescript-eslint/eslint-plugin/dist/configs/eslint-recommended 如何将 typescript-eslint 规则添加到 eslint - How to add typescript-eslint rules to eslint eslint 缩进和@typescript-eslint/indent 冲突 - eslint indent and @typescript-eslint/indent conflict
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM