Manifest.json Unexpected Token

前端 未结 6 1868
后悔当初
后悔当初 2021-02-10 20:38

Hello I pushed a react/express project up to heroku (https://polar-oasis-57801.herokuapp.com/) and received the following errors in the console: Chrome console error messages

相关标签:
6条回答
  • 2021-02-10 20:52

    I had a similar issue. I'll add it since this is the SO post I ended up at while trying to figure it out. I'd included some generated favicon markup to my "JS not allowed" file. My manifest.json is in my src/ directory, so the pasted in markup was referencing a manifest that wasn't in my public root. The boilerplate code then returned the "JS not allowed here" EJS HTML as the actual return value for the manifest.json, so the browser saw it as malformed JSON... Not ideal.

    So, if your router is going to return this sort of thing for bad HTTP requests, like Ant Design Pro does, it could be your problem.

    0 讨论(0)
  • 2021-02-10 20:54

    I added this change "/cat-cards/" in my server.js file so now it's app.use("/cat-cards/", express.static("client/build"));. Adding that change and pushing to Heroku made my website work. This helped me: https://github.com/facebook/create-react-app/issues/1812#issuecomment-286511320

    0 讨论(0)
  • 2021-02-10 20:57

    This error means that the request to manifest.json does not return a valid JSON response. Probably it returns an HTML, given the fact that it fails because of a starting <.

    Be sure to link the manifest.json correctly and make sure to preserve its integrity in the deployment process. Try to navigate to http://yoururl/manifest.json and check the result.

    EDIT1: it seems like your link to the manifest is broken. In https://github.com/bernar83/cat-cards/blob/master/client/public/index.html , try replacing

    <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
    

    with

    <link rel="manifest" href="manifest.json" />
    

    EDIT2: Just checked your Heroku link and can confirm the error. Your page tries to find the manifest.json under the path /cat-cards/manifest.json which is wrong. It should only be manifest.json

    0 讨论(0)
  • 2021-02-10 20:57

    Check the index.html inside build and inside your public folder. I had the same issues and just found that issue was with Html nothing else.

    Thanks Binod Singh

    0 讨论(0)
  • 2021-02-10 20:58

    I had the same issue I solve it by:

    1. Go into package.json file in your react app.

    2. You will see the homepage attribute at the top, remove it either copy that URL.

    • If you remove it then again create build and use that build in your express.static('./build').

    • If you copy it then use that url in your app.use("that copied url" , express.static('./build')) in your express server file.

    0 讨论(0)
  • 2021-02-10 20:59

    yeah I faced this problem and struggled a lot with it then I follow This helped me: https://github.com/facebook/create-react-app/issues/1812#issuecomment-286511320 link. it definitely works. I am thankful to the person who shares this link.

    0 讨论(0)
提交回复
热议问题