My deployment was successful, but I keep getting an 'Uncaught SyntaxError: Unexpected token '<'' error

@pizza When you encounter issues like this, you can debug locally.

To do so run your build (in this case npm run build), then go into the dist folder and see what you’ve output. If you want to see it in a browser you can run npx serve in the folder.

As far as I can tell, your main issue is that you do not want /public/ in your file paths.
Since you’re copying those files from /public/ into /dist/ as part of the build.

So the files don’t end up at…

/dist/public/css/index.css
/dist/public/img/logo.png
/dist/public/index.js

They end up at…

/dist/css/index.css
/dist/img/logo.png
/dist/index.js

You can see this by looking inside your /dist folder…

Since you’re deploying that /dist folder that portion of the path becomes the root, so your index.js file can be found at:
https://jihee-vinterior.netlify.app/index.js

Your css file is at:
https://jihee-vinterior.netlify.app/css/index.css

Your logo is at:
https://jihee-vinterior.netlify.app/img/logo.png

The reason that the /public/index.js file is returning html appears to be because you have a redirect set that is returning the index file for everything, which includes files that do not exist…

/* /index.html 200

Example:
https://jihee-vinterior.netlify.app/this/file/does/not/exist.js


As an additional tip, you should add a .gitignore file to the root of your repository that contains node_modules, to prevent all the dependencies being uploaded to your repository.

1 Like