reactjs - 由于缺少模块“eslint/lib/formatters/stylish”,我无法在部署到 GCP 后启动 React 应用程序
问题描述
我的 React 应用程序运行正常,但是当我部署到 Google Cloud Platform 时,我在浏览器中收到此错误
./src/index.js 模块构建失败:错误:找不到模块“eslint/lib/formatters/stylish”
此错误发生在构建期间,无法消除。
我已经阅读了很多关于这个的谷歌答案,但没有运气。
我试过删除 package-lock.json 和 node_modules 然后运行 npm install ,这没什么区别仍然得到错误
这是我的 package.json
{
"name": "AspNetCoreReactRedux",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.2.0",
"@material-ui/icons": "^4.2.1",
"bootstrap": "^4.1.3",
"jquery": "3.3.1",
"primereact": "3.1.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-redux": "^5.0.6",
"react-router-bootstrap": "^0.24.4",
"react-router-dom": "^4.2.2",
"react-router-redux": "^5.0.0-alpha.8",
"react-scripts": "^1.1.5",
"reactstrap": "^6.3.0",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0",
"rimraf": "^2.6.2",
"typeface-roboto": "0.0.54"
},
"devDependencies": {
"ajv": "^6.0.0",
"babel-eslint": "^7.2.3",
"cross-env": "^5.2.0",
"eslint": "^4.19.1",
"eslint-config-react-app": "^2.1.0",
"eslint-plugin-flowtype": "^2.50.3",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.11.1"
},
"eslintConfig": {
"extends": "react-app"
},
"scripts": {
"start": "rimraf ./build && react-scripts start",
"build": "react-scripts build",
"test": "cross-env CI=true react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"lint": "eslint ./src/"
}
}
我认为 package.json 有问题但不知道是什么
我读到我可以尝试:
如果您还没有弹出并看到此问题:
Remove anything with the word eslint from package.json
Remove package-lock.json and yarn.lock
Remove node_modules
Run npm install (or yarn if you use it)
但是这样做安全吗,那不会删除 eslint 吗?
解决方案
好的,我做到了,现在我可以部署
Remove anything with the word eslint from package.json
Remove package-lock.json and yarn.lock
Remove node_modules
Run npm install (or yarn if you use it)
推荐阅读
- javascript - 如果数组成员被包装,为什么打字稿泛型会推断出不同的类型?
- ruby-on-rails - Ruby on Rails 如何添加“require”语句,使其适用于所有模型
- python - 如何将 JSON(来自 python 请求)转换为 pandas 数据框
- android - 如何使用 Intent 从浏览器链接启动应用程序
- angular - 如何在 RxJS 中处理条件 observables
- python-3.x - 函数内的for循环
- python - 如何在 seaborn 条形图中将条形名称居中并向条形添加缩放选项?
- tcl - 如何将 MS Smart 引号“转换为 ascii?使用工具命令语言 (TCL)
- node.js - 为什么我的基本 hello world nodejs 应用程序无法在 Heroku 上运行?
- python - 使用 Python Pandas 将 JSON 文件转换为自定义表