reactjs - 在 create-react-app 上运行构建后出现空白页面

标签 reactjs create-react-app netlify

尝试在 netlify 上部署 create-react-app,但我的构建是空白页面。我正在使用 .env 文件加载 firebase api key ,这是构建的问题吗?

即使当我尝试在计算机上本地打开它时,它也是空白页面,并且在控制台中输出错误:“源文件“file:///event-app/static/js/main.108757a0 的加载失败。 js””

package.json: https://gist.github.com/Verthon/f82371ad2bb636b2e95c5b7697aa0bb5

➜  event-app git:(master) ✗ npm run build

> event-app@0.1.0 build /home/jurr/Projects/event-app
> node scripts/build.js

Creating an optimized production build...
Compiled with warnings.

./src/components/Router.js
  Line 12:  'withFirebase' is defined but never used  no-unused-vars

./src/components/Firebase.js
  Line 21:  'Firebase' is defined but never used  no-unused-vars

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

File sizes after gzip:

  282.86 KB  build/static/js/main.108757a0.js
  3.1 KB     build/static/css/main.8e671453.css

最佳答案

我通过设置解决了这个问题

"homepage": "."

package.json 中,根据 this doc

关于reactjs - 在 create-react-app 上运行构建后出现空白页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55568697/

相关文章:

node.js - npm 启动失败 : Error: start: `react-scripts start`

javascript - 为什么无法在 React hooks 组件中设置间隔 id?

javascript - 在 React 渲染 svg 之前,以编程方式将样式添加到 svg 中?

javascript - 使用 axios 获取数据并作为 props 导出到组件

reactjs - 如何为 React 应用程序保存图像

forms - 在提交表单后执行异步功能

ReactJS 浏览器应用程序无法看到 Docker Compose 网络中的内容

reactjs - 'react-scripts start'命令到底是什么?

node.js - socket.io 连接在生产环境中失败,在 localhost 中工作

javascript - FetchError : request to https://db. fauna.com/failed,原因:写入 EPIPE