我正在尝试在GCP上部署我的react应用程序。因此,在Gcloud shell中,我克隆了我的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我不知道为什么。当我在我的电脑上进行测试时,我根本没有这个问题。这是我的package.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"
]
}
}我试着在本地和全球安装eslint包,但这些都不起作用。这可能是一个环境问题,因为我直接在GShell上部署,但我仍然不知道如何解决这个问题。我需要些帮助。
发布于 2022-04-04 12:24:44
我相信Ryan链接了一个适当的堆栈溢出线程,其中一个社区用户提供了一个很好的答案。我将此作为任何访问这个问题的人的答案,以找到解决办法。
正在发生的事情是,当你运行npm时,它可能正在用eslint做一些检查。创建-反应-应用程序有一些检查,如果你有重复错误,所以这是有意义的关联你的构建。
这里出现的错误与eslint使用的一个名为子路径出口的节点特性有关,但它的支持是否成功取决于库是如何使用的。例如,当与jest一起使用时,会突出显示这会导致问题。对于流类型,eslint,这是引起问题的确切代码行。您还可以阅读有关类型记录eslint插件的类似报道。
解决方案和原因,造成这个问题的原因是,在https://github.com/flow-typed/eslint-plugin-ft-flow/pull/23中,修复是在eslint类型(考虑到原来的插件缺乏维护)的克隆中进行的。
一个问题是提出了创建-反应-应用,以交换与新的插件,这将有更多的维护和解决问题,你正在经历。问题链接是这里。
https://stackoverflow.com/questions/70573722
复制相似问题