微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

react npm build 在选项卡上显示网站图标,但它只是一个空白页面

如何解决react npm build 在选项卡上显示网站图标,但它只是一个空白页面

我有一个 typescript react 应用程序,我正在尝试为 delpoy 构建它。

运行 npm run buildserve -s build 后,我的应用程序启动,但它只是一个空白页面。图标在选项卡上可见。

我使用 @reach/router 作为我的路由器,不知道是否与问题有关。

我试过了:

  • homepage: "." 添加到 package.json
  • homepage: "./" 添加到 package.json
  • 在 package.json 中没有 homepage

在本地提供应用程序或将其部署到 Firebase 后,我只收到空白页面。我可以看到正在创建的块和部署的文件

部署的版本托管在:https://rezervavila-prod.web.app/


编辑:我在此 answer 上看到 browserRouter 对某些人来说是个问题。就我而言,我正在使用 @reach/router Router,但找不到修复方法

package.json

{
  "name": "app","homepage": ".","version": "0.1.0","private": true,"dependencies": {
    "@date-io/date-fns": "^1.3.13","@material-ui/core": "^4.11.3","@material-ui/icons": "^4.11.2","@material-ui/lab": "^4.0.0-alpha.57","@material-ui/pickers": "^3.3.10","@reach/router": "^1.3.4","@testing-library/jest-dom": "^5.11.4","@testing-library/react": "^11.1.0","@testing-library/user-event": "^12.1.10","@types/firebase": "^3.2.1","@types/jest": "^26.0.15","@types/node": "^12.0.0","@types/reach__router": "^1.3.7","@types/react-dom": "^17.0.0","@types/react-redux": "^7.1.16","axios": "^0.21.1","clsx": "^1.1.1","date-fns": "^2.19.0","firebase": "^8.2.7","moment": "^2.29.1","node-cache": "^5.1.2","prettier": "^2.2.1","query-string": "^6.14.0","react": "^17.0.1","react-big-calendar": "^0.33.2","react-dom": "^17.0.1","react-image-file-resizer": "^0.4.2","react-localize-redux": "^3.5.3","react-redux": "^7.2.2","react-scripts": "4.0.2","react-toastify": "^7.0.3","redux": "^4.0.5","redux-devtools-extension": "^2.13.8","redux-thunk": "^2.3.0","typescript": "^4.1.2","uniqid": "^5.3.0","web-vitals": "^1.0.1"
  },"scripts": {
    "start": "react-scripts start","build": "react-scripts build","build:development": "env-cmd -f .env.development npm run build","build:production": "env-cmd -f .env.production npm run build","test": "react-scripts test","eject": "react-scripts eject"
  },"eslintConfig": {
    "extends": [
      "react-app","react-app/jest"
    ]
  },"browserslist": [
    ">0.2%","not dead","not ie <= 11","not op_mini all"
  ],"devDependencies": {
    "@types/react": "^17.0.2","@types/react-big-calendar": "^0.30.0","@types/react-toastify": "^4.1.0","@types/uniqid": "^5.3.0","organize-imports-cli": "^0.8.0","tslint": "^6.1.3","tslint-config-prettier": "^1.18.0","tslint-react": "^5.0.0","tslint-react-hooks": "^2.2.2"
  }

解决方法

您的生产环境变量缺失 REACT_APP_API_URL

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?