简体   繁体   English

无法加载在“.eslintrc.json”中声明的插件“prettier”:找不到模块“eslint-plugin-prettier”

[英]Failed to load plugin 'prettier' declared in '.eslintrc.json': Cannot find module 'eslint-plugin-prettier'

I have a frontend project made with react that runs perfectly on vsCode, but when I uploaded it to Heroku I got this error:我有一个使用 react 制作的前端项目,可以在 vsCode 上完美运行,但是当我将它上传到 Heroku 时,我收到了这个错误:

Failed to load plugin 'prettier' declared in '.eslintrc.json': Cannot find module 'eslint-plugin-prettier'
Require stack:
- /app/node_modules/react-scripts/config/__placeholder__.js
Referenced from: /app/.eslintrc.json

I tried to uninstall eslint and installed it again but it didn't work.我试图卸载 eslint 并再次安装它,但它没有工作。 And since I'm kinda new I don't know where should I be looking around for an answer.而且由于我有点新,我不知道我应该在哪里寻找答案。

This is part of my package.json:这是我的 package.json 的一部分:

"eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
"devDependencies": {
    "eslint": "^7.16.0",
    "eslint-config-airbnb": "^18.2.1",
    "eslint-config-prettier": "^7.1.0",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-prettier": "^3.3.0",
    "eslint-plugin-react": "^7.21.5",
    "eslint-plugin-react-hooks": "^4.2.0",
    "prettier": "2.2.1"
  }

And this is my.eslintrc.json这是 my.eslintrc.json

{
    "env": {
        "browser": true,
        "es2021": true
    },
    "extends": [
        "plugin:react/recommended",
        "plugin:prettier/recommended"
    ],
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },
        "ecmaVersion": 12,
        "sourceType": "module"
    },
    "plugins": [
        "react",
        "prettier"
    ],
    "rules": {
        "no-console": "off",
        "prettier/prettier": ["error"],
        "consistent-return": "off",
        "react/jsx-indent": "off",
        "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
        "implicit-arrow-linebreak": "off",
        "react/button-has-type": "off",
        "jsx-a11y/label-has-associated-control": "off",
        "no-plusplus": "off",
        "react/prop-types": "off"
    }
}

I got the exact same problem.我遇到了完全相同的问题。 I solved this issue by removing existing eslint-config-prettier and eslint-plugin-prettier from package.json.我通过从 package.json 中删除现有的eslint-config- prettier 和eslint-plugin- prettier 解决了这个问题。 Then after re-installed with yarn (or npm) as dependencies (not as dev-dependencies).然后在重新安装纱线(或 npm)作为依赖项(而不是开发依赖项)之后。 Then again I pushed it to heroku, it worked!然后我又把它推到了 heroku,它成功了!

Had the same issue.有同样的问题。 To solve it, I downgraded eslint from version 8.3.0 to为了解决这个问题,我将 eslint 从8.3.0版本降级到

    "eslint": "^7.32.0",
    "eslint-config-prettier": "^7.2.0",
    "eslint-plugin-prettier": "^3.4.1",

暂无
暂无

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

相关问题 处理“无法加载在‘.eslintrc’中声明的插件‘react’:找不到模块‘eslint-plugin-react’”ESLint 错误 - Dealing with "Failed to load plugin 'react' declared in '.eslintrc': Cannot find module 'eslint-plugin-react'" ESLint error eslint-plugin-prettier 的目的是什么? - What is the purpose of eslint-plugin-prettier? 错误:无法加载在“.eslintrc.js”中声明的解析器“@babel/eslint-parser”:找不到模块“@babel/core/package.json” - Error: Failed to load parser '@babel/eslint-parser' declared in '.eslintrc.js': Cannot find module '@babel/core/package.json' ReactJS:无法加载在“package.json”中声明的插件“testing-library”:找不到模块“./eslint-utils” - ReactJS : Failed to load plugin 'testing-library' declared in 'package.json : Cannot find module './eslint-utils' 错误:无法加载在“.eslintrc”中声明的解析器“babel-eslint”:在 create-react-app 中找不到模块“babel-eslint” - Error: Failed to load parser 'babel-eslint' declared in '.eslintrc': Cannot find module 'babel-eslint' in create-react-app 无法加载在“package.json » eslint-config-react-app”中声明的插件“flowtype”:找不到模块“eslint/use-at-your-own-risk” - Failed to load plugin 'flowtype' declared in 'package.json » eslint-config-react-app': Cannot find module 'eslint/use-at-your-own-risk' 更漂亮的 eslint:使用 'prettier' 或 'plugin:prettier/recommended' 和 React Typescript airbnb eslint 配置 - Prettier eslint: use 'prettier' or 'plugin:prettier/recommended' with React Typescript airbnb eslint config 更漂亮,eslint - classProperties 解析器插件错误 - Prettier, eslint - classProperties parser plugin error 在eslintrc.json中关闭eslint规则 - Turning eslint rule off in eslintrc.json 错误:无法加载插件导入:在部署 create-react-app 时找不到模块“eslint-plugin-import” - Error: Failed to load plugin import: Cannot find module 'eslint-plugin-import' when deploying a create-react-app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM