Create React App已部署,但github页面显示manifest.json中的404 [英] Create React App is Deployed but github pages shows 404 from manifest.json

查看:175
本文介绍了Create React App已部署,但github页面显示manifest.json中的404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我在清单json文件中识别问题吗?

我在github页面上部署了一个简单的start-create-react应用程序,并通过命令行显示了已发布的内容,但是当我转到github页面时,页面不会加载.当我查看控制台时,收到来自manifest.json文件和静态CSS文件

的404错误消息

我到处都在寻找答案,但是我找不到解决方案,如果有人可以帮助的话,那将是很好的

解决方案

控制台中的最后一条错误消息显示:

 清单:行:1,列:1,意外令牌. 

请注意,代码的第1行第1列是尖括号:<

该尖括号是意外令牌".JSON文件应以 {而不是< 开头,这适用于XML或HTML文件.

Manifest.json是一个JSON文件,根据下面的Mozilla文章,应将其格式化为JSON格式,可能是"///"注释"./p>

下面,我提供了一个manifest.json文件的非常简短的示例.可以在此处找到包含更多信息的较长示例: https://developer.mozilla.org/zh-CN/docs/Mozilla/Add-ons/WebExtensions/manifest.json

  {"short_name":"awesome app",名称":"Awesome App"," start_url":".显示":独立","theme_color":#000000"," background_color" ;:"#ffffff"} 

此处显示了另一个JSON格式示例: https://json.org/example.html

Can anyone help me identify the problem to my manifest json file?

I deployed a simple starter create-react app to github pages and through the command line it shows that is is published but when I go to github pages page doesnt load. When I view the console I get this 404 error message coming from the manifest.json file , and static css file

I've searched everywhere for answers but I cant find a solution , if anyone could help that would be great

解决方案

The last error message in the console shows:

Manifest: line: 1, column: 1, Unexpected token.

Note that line 1, column 1 of your code is an angle bracket: <

That angle bracket is the "Unexpected token". JSON files are expected to begin with { not < which is appropriate for XML or HTML files.

Manifest.json is a JSON file which, according to the Mozilla article below, should be "formatted as JSON, with the possible exception of "//" comments."

Below I have included a very short example of a manifest.json file. A longer example with further information can be found here: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json

{
  "short_name": "awesome app",
  "name": "Awesome App",
  "start_url": ".",
  "display": "standalone",
  "theme_color": "#000000",
  "background_color": "#ffffff"
}

Another example of the JSON format is shown here: https://json.org/example.html

这篇关于Create React App已部署,但github页面显示manifest.json中的404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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