在构建和部署SyntaxError之后反应firebase错误:期望的表达式,得到'<' [英] React firebase error after build and deploy SyntaxError: expected expression, got '<'

查看:83
本文介绍了在构建和部署SyntaxError之后反应firebase错误:期望的表达式,得到'<'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过Firebase部署我的react应用程序,但是在部署之后,我得到一个空白页和SyntaxError:期望的表达式,得到了'<'.我认为这是因为它正在读取<从HTML,但我不确定如何解决此问题.以下是index.html表单,该表单是我的构建文件夹,该文件夹已初始化为firebase的来源

i'm trying to deploy my react app through firebase but after deploying i get a blank page and the SyntaxError: expected expression, got '<'. i think this is because it's reading the < from html but i'm not sure how to solve this. below is the index.html form my build folder which is initialized as the source for firebase

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
    <meta name="theme-color" content="#000000">
    <link href="../src/App.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Merriweather:900" rel="stylesheet">
    <link rel="manifest" href="/CV/manifest.json">
    <link rel="shortcut icon" href="/CV/favicon.ico">
    <title>Lorenzo Wijtman</title>
    <link href="/CV/static/css/main.1b15713e.css" rel="stylesheet">
</head>

<body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
    <script type="text/javascript" src="/CV/static/js/main.1b785adb.js"></script>
</body>

</html>

下面的我的firebase.json内容

my firebase.json content below

{
  "hosting": {
    "public": "build",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

推荐答案

您的HTML包含以下脚本,包括:

Your HTML contains this script include:

<script type="text/javascript" src="/CV/static/js/main.30b4dcd1.js"></script>

如果您尝试加载此 URL ,您会发现您正在取回原始HTML,而不是JavaScript文件.自从您告诉浏览器使用JavaScript以来,它一直在抱怨尖括号.

If you try to load this URL, you will see that you're getting back your original HTML, instead of a JavaScript file. Since you told the browser to expect JavaScript, it is complaining about the angular brackets.

您似乎没有部署/CV/static/js/main.30b4dcd1.js.由于您是在告诉Firebase Hosting将所有内容重写为/index.html,因此没有URL的匹配文件时,便会这样做.

It looks like you're not deploying a /CV/static/js/main.30b4dcd1.js. Since you're telling Firebase Hosting to rewrite everything to /index.html, that's what it does when there is no matching file for a URL.

这篇关于在构建和部署SyntaxError之后反应firebase错误:期望的表达式,得到'&lt;'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆