angular-fullstack / generator-angular-fullstack

Yeoman generator for an Angular app with an Express server
https://awk34.gitbook.io/generator-angular-fullstack
6.13k stars 1.24k forks source link

Uncaught SyntaxError: Unexpected token < #2708

Closed JosephSKh closed 6 years ago

JosephSKh commented 6 years ago
Item Version
generator-angular-fullstack 4.1.x
Node 8.9.4
npm 5.6.0
Operating System Ubuntu 15.10
etc etc
Item Answer
Transpiler TypeScript
Markup HTML
CSS CSS
Router ngRoute
Client Tests Jasmine
DB MongoDB
Auth Y
etc etc

I get Uncaught SyntaxError: Unexpected token < in the browser after the initial launch of the generator and stuck at Loading...

Awk34 commented 6 years ago

What are the steps you take to run your app?

JosephSKh commented 6 years ago

@Awk34 I'm using the configurations above, I've already started my mongo db engine, and i use gulp serve

JosephSKh commented 6 years ago

@Awk34 a small hint, sometimes it works with npm run start:client ,,, but never with gulp serve

albert-92 commented 6 years ago

Are you sure you are using 4.1.x and not 5.x.x?

https://github.com/angular-fullstack/generator-angular-fullstack/issues/2711 has the same Problem for 5.0.0-rc1.

Check https://angular-fullstack.github.io/get-started/running/

It is npm run start:server and npm run start:client instead of gulp serve in 5.x.x

JosephSKh commented 6 years ago

@albert-92 you mean it's gulp serve for AngularJs and npm run start:whatever for Angular 2+ ?

JosephSKh commented 6 years ago

@albert-92 oh ok I think that explains it, I'm using v5.0.0-rc.1

albert-92 commented 6 years ago

you mean it's gulp serve for AngularJs and npm run start:whatever for Angular 2+ ?

Exactly

koraysels commented 6 years ago

I also have this problem. I am running npm run start:server and npm run start:client and still I get the unexpected token error and it is stuck on the "Loading... "

fedfigca commented 6 years ago

I think the problem is we're pointing our browsers to port 9000 but the full webpack/gulp magic is happening at 8080, the output of the npm run start:* is confusing and the only url we see is localhost:9000 so we go there by mistake... The error is because express sends app.html as the javascript files because of the routing in the plain server running at 9000

JosephSKh commented 6 years ago

@koraysels make sure you are using Version 4.1.x not v5.0.0-rc.1 Run npm run start:server then npm run start:client

koraysels commented 6 years ago

what do you mean ? I want angular fullstack with angular 2+ .. It is working if i go to port 8080 instead of 9000. so that's a win! now I only need to figure out how to get the 'client' working in a docker container.. 'server' is working but 'client' does nothing :(

Awk34 commented 6 years ago

npm run start:client should always display that it's output is shown at localhost:8080 (or a different port if you changed it. This is coming directly from Webpack.

I appreciate the comments. I can only improve the project with either direct contributions or specific comments I can take action on.

There's a super-old PR I made involving Docker: https://github.com/angular-fullstack/generator-angular-fullstack/pull/2290/files . I plan on re-doing this in the future, so the PR isn't quite up-to-par, but it might give you some more info @koraysels

malkyfaith commented 6 years ago

My 'npm run start:client' runs fine but 'npm run start:server' causes this "Uncaught SyntaxError: Unexpected token <". I am not understanding what's the problem? I am using

Awk34 commented 6 years ago

@malkyfaith are you opening your browser to http://localhost:8080?

malkyfaith commented 6 years ago

@Awk34 I am running two different power shells to access client on 8080 and server on 9000.