cornflourblue/angular2-jwt-authentication-example

metadata_resolver.js Uncaught Error: Can't resolve all parameters for UserService: (Http, ?).

nextstopsun opened this issue · 2 comments

I'm trying to run this example as an Angular CLI app. It uses webpack by default instead of SystemJS. The bundle gets built with no errors, but I've got this error on the page:

metadata_resolver.js:508 Uncaught Error: Can't resolve all parameters for UserService: (Http, ?).

CompileMetadataResolver.getDependenciesMetadata @   metadata_resolver.js:508
CompileMetadataResolver.getTypeMetadata @   metadata_resolver.js:405
(anonymous function)    @   metadata_resolver.js:552
CompileMetadataResolver.getProvidersMetadata    @   metadata_resolver.js:532
CompileMetadataResolver.getNgModuleMetadata @   metadata_resolver.js:285
RuntimeCompiler._compileComponents  @   runtime_compiler.js:126
RuntimeCompiler._compileModuleAndComponents @   runtime_compiler.js:64
RuntimeCompiler.compileModuleAsync  @   runtime_compiler.js:55
PlatformRef_._bootstrapModuleWithZone   @   application_ref.js:303
PlatformRef_.bootstrapModule    @   application_ref.js:285
(anonymous function)    @   main.ts:12
__webpack_require__ @   bootstrap 4990ebf…:52
(anonymous function)    @   zone.js:1327
__webpack_require__ @   bootstrap 4990ebf…:52
webpackJsonpCallback    @   bootstrap 4990ebf…:23
(anonymous function)    @   main.bundle.js:1

I guess it has something to do with the second argument of UserService constructor, which is of type AuthenticationService: private authenticationService: AuthenticationService.

@cornflourblue Can you please give a clue how to solve this error? I'm a noob in Angular and webpack seems a lot more easier (with literally no configuration) than SystemJS.

I'm doing the same thing and have the same problem.

I'm not sure why this worked but I fixed it by changing import { AuthenticationService } from './index'; to import { AuthenticationService } from './authentication.service'; in user.service.ts

I was literally about to try that, then thought 'nah - why would that make a difference?'
Then found @morgdenn 's comment - and it worked for me, too!

I'd love to know why this makes a difference!