javascript – When compiling Vue-cli project and serving with nginx, console prints ” Uncaught SyntaxError: Unexpected token ‘
I am trying to run my Vue-Cli project on my server with nginx. I am fairly certain my nginx is set up correctly but you can look it over.
This is on vue 3.2.13
, nginx 1.18.0
and ubuntu 20.04.4
root /var/www/html/;
index index.html;
location /vueProject/ {
try_files $uri /vueProject/dist/index.html;
}
When visiting the page the console gives 2 errors
Uncaught SyntaxError: Unexpected token '<'
both linking to Javascript files /js/chunk-vendors.44e4eb0a.js
& /js/app.3856adea.js
.
From what I have read it seems to not be able to fetch those files. When I view them in the dev tools they aren’t loaded, they just appear as the index.html file.
I have tried changing publicPath:
in vue.config.js but that didn’t change it and adding .
in front of the path to the files didn’t change it either. So I am thinking the files might not be loaded by nginx and if that is the issue how would I solve that?
Read more here: Source link