Uncaught syntax error on Netlify not present when building locally

answered
#1

Briefly summarize the issues you have been experiencing.
Deployed site to netlify, site works fine locally as well as on Google cloud products (just to expensive) on deployment I get no errors, but when I go to the site I get an uncaught syntax error “<” I have checked that the files are the same name, and that nothing has changed and from what I can tell nothing has changed.
Please provide a link to your live site hosted on Netlify
https://toryredner.tech/
What have you tried as far as troubleshooting goes? Do you have an idea what is causing the problem?
Tried rebuilding the site and clearing the cache, deleted the build folder and rebuilding it.

Do you have any other information that is relevant, such as links to docs, libraries, or other resources?
This is a basic react app, with no backend

any help is greatly appreciated

#2

hi there, did you already work through these suggestions?

#3

Yes, as far as I can tell the file names or the path hasnt been changed

#4

Hi there @tch180,

It looks like you’re prefixing all of your links and src with /portv4/ while your site doesn’t exist in that subdirectory. Without digging in to your code I can’t tell you why it’s doing that but create-react-app will replace instances of %PUBLIC_URL% with the actual public URL for the files that it generates.

1 Like
#5

@futuregerald
Thanks that helps some, it should becoming from the build folder right? still a novice at deploying, I have gotten it to work on other platforms, like google and githubpages, tried godaddy that was a mess.

#6

Not sure what you mean exactly by “it should be coming from the build folder”. More details are always more useful to getting the best help :slight_smile: I’d suggest something like:

  • when I browse https://site/path
  • I see X happening - the exact error message in my browser developer tools is file not found for path https://x/z.js
  • but I expect Y to happen instead: the page does not have any styling as it should from my screenshot from local
#7

@fool so when I navigate to the website toryredner.tech the homepage should be displayed,

  • when going to the site, I get an uncaught syntax error that does not happen locally in the console.
  • the file names match with the build and each file from the build show in the sources.

there is no rendering being done @futuregerald mentioned that this may be due to react prefixing as well as it building from portv4/ which I thought meant that it wasn’t building from the build folder. I could be completely missing what @futuregerald was talking about.
below is a screen of what render locally as well as on GCP and amazon and Ghp

#8


on netlify

#9


Sources

#10

OK. So usually this is more a problem of the build than the service (as your title implies). The usual reason for the uncaught syntax error is almost certainly shown here:

(tl;dr service worker referring to stale content, and/or you change filenames between builds and your front-end doesn’t have any logic to reload in that case - workarounds described in the linked spectrum thread).