npm 错误 in 无法加载在 'package.json » eslint-config-react-app' 中声明的插件 'flowtype': 找不到模块 'eslint/use-a



我正试图在GCP上部署我的react应用程序。所以在Gcloudshell中,我克隆了我的react项目并键入

npm install
npm run build

然而,我得到了这个错误:

ERROR in Failed to load plugin 'flowtype' declared in 'package.json » eslint-config-react-app': Cannot find module 'eslint/use-at-your-own-risk'
Require stack:
- /home/oizfwvlh/Portfolio/portfolio/node_modules/eslint-plugin-flowtype/dist/utilities/getBuiltinRule.js
- /home/oizfwvlh/Portfolio/portfolio/node_modules/eslint-plugin-flowtype/dist/rules/noUnusedExpressions.js
- /home/oizfwvlh/Portfolio/portfolio/node_modules/eslint-plugin-flowtype/dist/index.js
- /home/oizfwvlh/Portfolio/portfolio/node_modules/@eslint/eslintrc/dist/eslintrc.cjs

我不知道为什么。我在电脑上测试时根本没有这个问题。这是我的软件包.json:

{
"name": "portfolio",
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.7.1",
"@emotion/styled": "^11.6.0",
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@mui/icons-material": "^5.2.5",
"@mui/material": "^5.2.5",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"bootstrap": "^5.1.3",
"chart.js": "^3.7.0",
"chartjs-plugin-deferred": "^1.0.2",
"emailjs-com": "^3.2.0",
"jquery": "^3.6.0",
"node-sass": "^7.0.0",
"popper.js": "^1.16.1",
"react": "^17.0.2",
"react-bootstrap": "^2.1.0",
"react-chartjs-2": "^4.0.0",
"react-dom": "^17.0.2",
"react-router-dom": "^6.2.1",
"react-scripts": "5.0.0",
"react-vertical-timeline-component": "^3.5.2",
"web-vitals": "^2.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

我尝试在本地和全局安装esint包,但都不起作用。这可能是一个环境问题,因为我直接部署在GShell上,但我仍然不知道如何解决这个问题。我需要一些帮助。

我相信Ryan已经链接了一个合适的stackerflow线程,社区用户在其中提供了一个很好的答案。我发布这篇文章是为了回答任何访问这个问题以找到解决方案的人。

现在的情况是,当你运行npm-start时,它可能正在对esint进行一些检查。create-rect应用程序有一些检查,如果你有esint错误,就会破坏你的构建,所以它们是有关联的。

您在这里得到的错误与esint使用的一个名为子路径导出的节点功能有关,但它的支持是偶然的,这取决于库的使用方式。例如,当与jest一起使用时,这会引起问题。对于流类型esint插件,这正是导致问题的代码行。您还可以阅读关于typescript esint插件的类似问题报告。


解决方案和原因,导致此问题的原因是在esint插件流类型的克隆中进行了修复(考虑到原始插件缺乏维护(https://github.com/flow-typed/eslint-plugin-ft-flow/pull/23.

create-rect应用程序提出了一个问题,用新的插件替换插件,这样可以进行更多的维护并解决您遇到的问题。问题链接在这里。

最新更新