SyntaxError: Invalid or unexpected token on rendering server side on React

SyntaxError: Invalid or unexpected token on rendering server side on React.

Hi. Can you please explain more about the issue you are experiencing and what question you are asking?

Image not displaying, though is in build files. React
I’m having an issue getting an image to appear within my React project. I’ve done it before and actually copied the same exact code to put it into my project, but for some reason nothing is showing up. I looked in the console and inspected the image and it’s showing that there is something there, but just not rendering somehow. Nothing I search for online has a similar issue so I’m wondering if I’m just missing something, and that’s what causing it not to render.

Given you’re using ES6 imports in your React and you’re probably using commonjs imports server-side, it’s probably trying to run ES6 on your server and failing there. Webpack won’t help here since it bundles code for your client and you’re hitting the error on your server. Hopefully this helps you in your search / gives you a path forward.

1 Like

Wow, thanks a lot for pointing these out. My configuration is exactly as you have highlighted. But is there any fix you can suggest please?

You basically want to allow ES6 on your server - here’s a random article I found on Google (disclaimer: have not tried it myself) but if it doesn’t work if you just look for “express es6” there should be plenty of resources and hopefully one will work:

1 Like

You have just saved me hours of frustrated debugging. Thanks.

1 Like