How to fix Svelte error – Uncaught SyntaxError: Unexpected token <

If you are working in a Svelte project, you may have come across the following error while running the command npm run dev.

Uncaught SyntaxError: Unexpected token <

Thankfully, this relatively straightforward to address. To remedy this error, set the cache to disabled in your browser’s developer tools.

This commonly occurs when you have created a new instance of localhost for your project locally. The browser then fetches a previous reference to index.html and causes the error.

Proudly published with Gatsby