如何解决无法加载在“.eslintrc.json”中声明的插件“prettier”:找不到模块“eslint-plugin-prettier”
我有一个用 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
我尝试卸载 eslint 并重新安装,但没有用。由于我是个新手,我不知道应该去哪里寻找答案。
这是我的 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"
}
这是我的 .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"
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。