Syntax Error in Angular App: Unexpected token <

后端 未结 30 2077
独厮守ぢ
独厮守ぢ 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:34

    I had the same issue:

    1) I ran the command

    ng build --aot --prod
    

    2) Everything compiled without an error

    3) I deleted all the files on the server and copied it all across via FTP(FileZilla) to a windows Azure server

    4) Sometimes I get the error

    Unexpected token <
    

    and other-times not

    Yesterday I noticed that the main[hash].js was missing on the server and that Filezilla did not give me an error copying it.

    I then tried copying only that file.It did not work. When I removed the hash part from the filename it copies without a problem.

    Work-a-round

    Run:

    ng  build --aot --prod --output-hashing none
    

    Which works every-time.

    So either Filezilla or Windows Server does not allow filenames with a specific length or it does not like certain hashes.

提交回复
热议问题