Dettlaff
Dettlaff

Reputation: 210

Uncaught SyntaxError: Unexpected token '<' When using create-react-app develop mode

im getting this error "Uncaught SyntaxError: Unexpected token '<' " when using CRA development server. Usually clearing cache and reloading helps. How can i fix that? Link repo in which my problem occurs: https://github.com/MaciejWiatr/Cookup/tree/develop

Upvotes: 1

Views: 1902

Answers (1)

Dettlaff
Dettlaff

Reputation: 210

Okay, it seems that I've figured it out. It was all serviceWorker's fault. I've added the following snippet and everything started working fine

if (!process.env.NODE_ENV || process.env.NODE_ENV === "development") {
    // dev code
    serviceWorker.unregister();
} else {
    // production code
    serviceWorker.register();
}

Upvotes: 2

Related Questions