Vue error: Uncaught SyntaxError: Unexpected token ‘<‘ solution

created at 09-08-2022 views: 6


After the code of the vue project is packaged and deployed to the server, the console reports the following error after opening:

Uncaught SyntaxError: Unexpected token ‘<‘

reason & solution

In fact, in my case, it is not a code problem, but a problem of resource public path setting. The solution is as follows:


publicPath: '/',

Just set the publicPath here to "/", don't add a dot in front (like ./), and the problem will be solved after the change.

Tip: In fact, the system defaults to '/', but when deploying, I saw other people's articles saying that they need to be changed, so I added a . to it. Later, I found out that it is ok not to change it, but it will report an error. The latest version of vue no longer needs to modify the default path when deploying.

created at:09-08-2022
edited at: 09-08-2022: