Reputation: 89
I've recently been looking into building a PWA, using angular 6 and Node.js, and have been following the tutorial found here . I have followed the steps up until the lighthouse portion and upon calling http-server I received a ERR_INVALID_REDIRECT when opening the server. Upon further inspection it appears that I am receiving an unexpected token error. This has led me to believe that there is an encapsulation issue in the program but I have been unable to find anything on the issue. Specifically, I believe the browser is interpreting some JS as HTML but I've had little luck finding where it is occurring. Has anyone encountered a similar issue before? Thank you in advance.
I am able to serve the page up by using the command ng serve --open.
Looking in the developers tool it appears that it request is stalling. Changing the Authentication in the ISS manager resulted in the same issue.
References:
Unexpected token < in first line of HTML
https://github.com/typeorm/typeorm/issues/3629
Final Project: https://github.com/techiediaries/angular-pwa
Upvotes: 3
Views: 1978
Reputation: 332
Faced the same issue as well opening a PWA on localhost. As suggested by @ssh-uunen , i tried opening the url by appending index.html at the end and it opened eg: http://127.0.0.1:8080/index.html.
The issue was due to http-server version (https://github.com/http-party/http-server/issues/525). Try to upgrade/downgrade http-server version in your project.
1.npm uninstall http-server
2.npm install [email protected]
Upvotes: 0
Reputation: 311
Try to access to index.html directly, it might be related to https://github.com/indexzero/http-server/issues/525
Upvotes: 3