我正在尝试将我的应用程序部署到 firebase 托管,但我在控制台中收到此错误 Uncaught SyntaxError: Unexpected token '<'
在几个*.chunk.js
文件。我已经部署了my app to gh-pages一切都很好。我也尝试将它部署到 netlify 托管,但我有 Failed to load resource: the server responded with a status of 404 ()
在所有 *.js 文件中。
这是我的 firebase.json
:
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
],
"headers": [
{"source": "/service-worker.js", "headers": [{"key": "Cache-Control", "value": "no-cache"}]}
]
}
}
出于某种原因,这些 *.chunk.js
文件包含一些 html 代码
image from the console
但同时我的本地main.chunk.js
才不是
image of local file
最佳答案
显然,我的 package.json
文件中存在冲突。 gh-pages
必需 "homepage": ...
in package.json
以某种方式搞乱了对其他托管服务提供商的部署。
关于reactjs - 未捕获的语法错误 : Unexpected token '<' while deploying create react app to firebase hosting,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63439559/