Angular-cli: Error "Uncaught (in promise): Error: No provider for t!" only in prod build

Created on 27 Mar 2017  Â·  5Comments  Â·  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.0.0
node: 7.6.0
os: win32 x64
@angular/animations: 4.0.0
@angular/common: 4.0.0
@angular/compiler: 4.0.0
@angular/core: 4.0.0
@angular/forms: 4.0.0
@angular/http: 4.0.0
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 4.0.0
@angular/platform-browser-dynamic: 4.0.0
@angular/router: 4.0.0
@angular/cli: 1.0.0
@angular/compiler-cli: 4.0.0

Repro steps.

  • Add providers to the root app module like :
    @NgModule({ providers: [ HttpClientService, CookieService ]})
  • ng serve -prod

The log given by the failure.

ERROR Error: Uncaught (in promise): Error: No provider for t!
Error
at y (polyfills.eff75a4….bundle.js:36)
at O (vendor.40c10a7….bundle.js:204)
at E (vendor.40c10a7….bundle.js:204)
at t._throwOrNull (vendor.40c10a7….bundle.js:351)
at t._getByKeyDefault (vendor.40c10a7….bundle.js:351)
at t._getByKey (vendor.40c10a7….bundle.js:351)
at t.get (vendor.40c10a7….bundle.js:351)
at e.get [as _CookieService_110] (main.bc04250….bundle.js:1)
at e.get [as _HttpClientService_111] (main.bc04250….bundle.js:1)
at e.getInternal (main.bc04250….bundle.js:1)
at e.t.get (vendor.40c10a7….bundle.js:365)
at un (vendor.40c10a7….bundle.js:281)
at an (vendor.40c10a7….bundle.js:281)
at sn (vendor.40c10a7….bundle.js:281)
at $e (vendor.40c10a7….bundle.js:281)
at y (polyfills.eff75a4….bundle.js:36)
at O (vendor.40c10a7….bundle.js:204)
at E (vendor.40c10a7….bundle.js:204)
at t._throwOrNull (vendor.40c10a7….bundle.js:351)
at t._getByKeyDefault (vendor.40c10a7….bundle.js:351)
at t._getByKey (vendor.40c10a7….bundle.js:351)
at t.get (vendor.40c10a7….bundle.js:351)
at e.get [as _CookieService_110] (main.bc04250….bundle.js:1)
at e.get [as _HttpClientService_111] (main.bc04250….bundle.js:1)
at e.getInternal (main.bc04250….bundle.js:1)
at e.t.get (vendor.40c10a7….bundle.js:365)
at un (vendor.40c10a7….bundle.js:281)
at an (vendor.40c10a7….bundle.js:281)
at sn (vendor.40c10a7….bundle.js:281)
at $e (vendor.40c10a7….bundle.js:281)
at y (polyfills.eff75a4….bundle.js:36)
at l (polyfills.eff75a4….bundle.js:36)
at l (polyfills.eff75a4….bundle.js:36)
at polyfills.eff75a4….bundle.js:36
at t.invokeTask (polyfills.eff75a4….bundle.js:36)
at Object.onInvokeTask (vendor.40c10a7….bundle.js:365)
at t.invokeTask (polyfills.eff75a4….bundle.js:36)
at e.runTask (polyfills.eff75a4….bundle.js:36)
at a (polyfills.eff75a4….bundle.js:36)
_ @ vendor.40c10a7….bundle.js:197
t.handleError @ vendor.40c10a7….bundle.js:351
next @ vendor.40c10a7….bundle.js:365
e.object.i @ vendor.40c10a7….bundle.js:365
e.__tryOrUnsub @ vendor.40c10a7….bundle.js:766
e.next @ vendor.40c10a7….bundle.js:766
e._next @ vendor.40c10a7….bundle.js:766
e.next @ vendor.40c10a7….bundle.js:766
EEr4.e.next @ vendor.40c10a7….bundle.js:463
e.emit @ vendor.40c10a7….bundle.js:365
t.triggerError @ vendor.40c10a7….bundle.js:365
onHandleError @ vendor.40c10a7….bundle.js:365
t.handleError @ polyfills.eff75a4….bundle.js:36
e.runGuarded @ polyfills.eff75a4….bundle.js:36
r @ polyfills.eff75a4….bundle.js:36
a @ polyfills.eff75a4….bundle.js:36

Desired functionality.

It's working with dev build using simply ng serve so it should also work with ng serve -prod.
It seems that the minimized vendor.bundle.js file is broken when using production build.

Most helpful comment

I get the same problem, it works well with ng serve, however it gives
ERROR Error: Uncaught (in promise): Error: No provider for e! Error: No provider for e!
when I use ng serve --prod --aot

All 5 comments

I get the same problem, it works well with ng serve, however it gives
ERROR Error: Uncaught (in promise): Error: No provider for e! Error: No provider for e!
when I use ng serve --prod --aot

FYI - In my case this problem was caused by angular2-logger. See https://stackoverflow.com/a/43410786/156477 for the fix.

You can disable the TerserPlugin for the new angular version

   optimization: {
        noEmitOnErrors: true,
        minimizer: [
            new webpack_1.HashedModuleIdsPlugin(),
            // TODO: check with Mike what this feature needs.
            new bundle_budget_1.BundleBudgetPlugin({ budgets: buildOptions.budgets }),
            new cleancss_webpack_plugin_1.CleanCssWebpackPlugin({
                sourceMap: buildOptions.sourceMap,
                // component styles retain their original file name
                test: (file) => /\.(?:css|scss|sass|less|styl)$/.test(file),
            }),
            /* new TerserPlugin({
                sourceMap: buildOptions.sourceMap,
                parallel: true,
                cache: true,
                terserOptions,
            }), */
        ],
    },

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NCC1701M picture NCC1701M  Â·  3Comments

rwillmer picture rwillmer  Â·  3Comments

gotschmarcel picture gotschmarcel  Â·  3Comments

donaldallen picture donaldallen  Â·  3Comments

sysmat picture sysmat  Â·  3Comments