Syntax Error in Angular App: Unexpected token <

后端 未结 30 2176
独厮守ぢ
独厮守ぢ 2020-12-02 20:16

I have an Angular app which runs perfectly in my local and production environment.. After a tiny change I made, I ran the app locally and it works fine.. Then I built the pr

30条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 20:22

    The problem is with the part of index.html file, it seems angular generates build file inside dist/{yourProjectName}/ but the index.html files goes through the dist/ for build files. Now you have 2 options:

    1. Change the part of the index.html file to but now you have inconsistency between the ng serve command and ng build and you can't see your project through ng serve. So you have change that part every time!

    2. The seccond approach that I recommend, is just changing the output path of the project! Go to your angular.json file of your project and change the "outputPath": "dist/{yourProjcetName}", to "outputPath": "dist/" and don't change the base href!

提交回复
热议问题