Urgh! I got so bored with this error, I didn’t know what was going on.
I found out that there was a problem with my AppComponent which meant that my AppModule was complaining. What problem though? I had to compile my angular code to find out. When I used ng build or ng serve, I couldn’t work out what the problem was from the browser. Granted, this is all new to me, but I expected there to be a line number and a bit of searching in stackOverflow. However, I found that I could compile my code Ahead-Of-Time using this command: ng build –aot
Then I actually found the problem:
ERROR in : Unexpected value ‘AppComponent in C:/single-page/frontend/src/app/app
.component.ts’ declared by the module ‘AppModule in C:/single-page/frontend/src/
app/app.module.ts’. Please add a @Pipe/@Directive/@Component annotation.
src/app/app.component.ts(8,2): error TS2554: Expected 1 arguments, but got 0.
I had been trying to get the HTTP stuff to work and it wasn’t, and had changed the @Component to @Injectable for some reason. I must have copied it from somewhere. Anyway, I changed that and it worked.
Note, you can get this error if you don’t format the @Component right too, for example if you stick a semi-colon on the end of it.
@Component({}) – is ok
@Component({}); – is not ok