Skip to content

Uncaught SyntaxError: Unexpected token < #4718

Description

@Rodrigo77777

Is this a bug report?

Yes, related to #1812, but I could not get the solution there to work for me.

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

Unexpected token, found one related issue but could not figure out what I'm doing wrong from there.

Environment

Environment:
OS: Windows 10
Node: 10.5.0
Yarn: Not Found
npm: 6.1.0
Watchman: Not Found
Xcode: N/A
Android Studio: Not Found

Packages: (wanted => installed)
react: ^16.4.1 => 16.4.1
react-dom: ^16.4.1 => 16.4.1
react-scripts: 1.1.4 => 1.1.4

Steps to Reproduce

(Write your steps here:)

  1. Make sure app works in development mode.
  2. Run npm run build
  3. Try to access url hosting server

Expected Behavior

Expected it to open the React App as it does in development mode.

Actual Behavior

Something is not quite working and app does not render, throwing the error on the title on the first character of the file. You can see it for yourself at cosmictechnology.co.uk, as that is where I'm hosting the app. Again, it works fine on dev mode using node and express.js, but once I try to run it on an actual server something goes wrong. The url to the main.js and main.css files seems correct, so I am not sure where I am going wrong. I'm also attaching some screenshots, just in case that helps!
1
2
3
4

Also, just like #1812, I'm running the client from a weird location. So my node.js index file is on the root folder of the project, the express configuration you see on the screenshot above is inside a ./src folder, and finally the client build is inside ./client/build folder. so to get from the express file to the client the path of ../client/build should be correct. I've also set up the homepage parameter on the client package.json to be '/client/build', and that seems to be fetching the files from the correct folder, as the first two screenshots show. But something is still not quite right and I can't figure out what it is!
Any help would be much appreciated!

Reproducible Demo

I'm happy to share my express.js code here or anything that might be pertinent, just not sure what might be the most useful

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions