reactjs - 未捕获的语法错误 : Unexpected token '<' while deploying create react app to firebase hosting

标签 reactjs firebase create-react-app github-pages

我正在尝试将我的应用程序部署到 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/

相关文章:

javascript - 如何在 react 组件构造函数中设置间隔?

reactjs - 使用 create-react-app 时如何修复 React 15.5.3 PropTypes 已弃用警告

reactjs - 使用 create-react-app 时使用自定义构建输出文件夹

javascript - 从子组件访问父 prop/attribute

javascript - 从 JSON 中删除 src 以创建图像

javascript - 接下来如何在react SSR框架中使用TS+css+scss?

swift - Firebase Firestore - 或查询替代方案

ios - Firestorage 关闭时显示图像的正确方法或在 Firestorage for iOS 中加载预览时出错

ios - self Controller nil webview

css - 导入本地字体到create-react-app元素