【发布时间】:2021-02-21 03:53:02
【问题描述】:
我已经使用 React 构建了我的博客,它在开发模式下运行良好,但是如果我将它上传到 Netlify,它在生产构建中显示为空白页面并出现错误。
Uncaught TypeError: Cannot convert undefined or null to object
at Function.getPrototypeOf (<anonymous>)
at Object.<anonymous> (utils.js:48)
at f (index.html:1)
at Object.<anonymous> (URL.js:4)
at f (index.html:1)
at Object.<anonymous> (webidl2js-wrapper.js:3)
at f (index.html:1)
at Object.<anonymous> (index.js:3)
at f (index.html:1)
at Object.<anonymous> (api.js:7)
一开始我删除了整个 src 和 public 文件夹,这是因为我使用相同的方法上传我的其他 react 项目并且它按预期工作。
package.json:
{
"name": "frontend",
"homepage": ".",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.5",
"@testing-library/user-event": "^12.7.1",
"axios": "^0.21.1",
"dompurify": "^2.2.6",
"jsdom": "^16.4.0",
"marked": "^2.0.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.2",
"web-vitals": "^1.1.0"
},
"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"
]
}
}
【问题讨论】:
-
????????请在此处以纯文本形式发布代码、错误、示例数据或文本输出,而不是难以阅读、无法复制粘贴以帮助测试代码或在答案中使用的图像,并且对依赖的人构成障碍在屏幕阅读器或翻译工具上。您可以编辑问题以在问题正文中添加代码。为了便于格式化,请使用
{}按钮标记代码块,或使用四个空格缩进以获得相同的效果。 屏幕截图的内容无法搜索、作为代码运行或复制和编辑以创建解决方案。
标签: reactjs