How can I fix SyntaxError: Cannot use import statement outside a module’ and ‘Unexpected token <' errors in Node.js v18.16.0?

I have been trying to create my first React app and when I tried to run it I got these errors for respective code.

1) 1st image is code of index.js file which is giving error-

https://i.stack.imgur.com/Cby5r.png

And error it is giving is 2nd image-
https://i.stack.imgur.com/zs0YF.png

I added "type" : module which solved error but i got different error which is 3rd image-
https://i.stack.imgur.com/UqeU9.png

2)4th image is code of App.js file which is giving error-

https://i.stack.imgur.com/RoD5I.png

And error it is giving is 5th image-
https://i.stack.imgur.com/qfCC6.png

I was expecting the output as a webpage showing Hello World! but instead of which web browser is displaying a blank page.

Leave a Reply

Your email address will not be published.