Skip to content

ng build results in Uncaught Error: Can't resolve all parameters for #10685

@alexfung888

Description

@alexfung888

Versions

Angular CLI: 6.0.0
Node: 8.11.1
OS: win32 x64
Angular: 6.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, http, material, platform-browser
... platform-browser-dynamic, platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.6.0
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.0
@angular/flex-layout              6.0.0-beta.15
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.0
@schematics/update                0.6.0
rxjs                              6.0.0
typescript                        2.7.2
webpack                           4.6.0

Repro steps

ng build
deploy or host with http-server
open using browser

Observed behavior

application will produce at run time:
Uncaught Error: Can't resolve all parameters for [my service name] (?, ?)

does not happen with ng serve

Desired behavior

I expect the application to run normally, like in ng serve

Mention any other details that might be useful (optional)

Circumvention: change

  providers: [ AuthService ]
@injectable()
export class AuthService {

to, for each service

@injectable({providedIn: 'root'})
export class AuthService {

After this, application will complain at run time

compiler.js:215 Uncaught Error: Can't resolve all parameters for HomeComponent: (?, ?, ?, ?).
at syntaxError (compiler.js:215)

In order to circumvent that, I would need to add "@Inject()" to each dependency of every component. This is a lot of work and I have only manually updated one of them.

I also submitted an issue to angular
angular/angular#23734
but I think this is probably a cli issue instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs: repro stepsWe cannot reproduce the issue with the information given

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions