EXCEPTION: No provider for t! in production build only
Please provide us with the following information:
OS?
OS X 10.11.6
Versions.
@angular/cli: 1.0.0-beta.31 node: 6.9.5 os: darwin x64 @angular/common: 2.4.7 @angular/compiler: 2.4.7 @angular/core: 2.4.7 @angular/forms: 2.4.7 @angular/http: 2.4.7 @angular/platform-browser: 2.4.7 @angular/platform-browser-dynamic: 2.4.7 @angular/router: 3.4.7 @angular/cli: 1.0.0-beta.31 @angular/compiler-cli: 2.4.7
Repro steps.
My repo is here: https://github.com/scottschafer/BowlBlaster.git
If I run "ng serve", the application works just fine. However, if I deploy to github pages, or just use "ng serve -prod", I get a series of cryptic errors in the browser log.
The log given by the failure.
EXCEPTION: No provider for t! t.handleError @ vendor.b857c3e….bundle.js:435 vendor.b857c3e….bundle.js:435 ORIGINAL STACKTRACE: t.handleError @ vendor.b857c3e….bundle.js:435 vendor.b857c3e….bundle.js:435 Error: DI Error at e.d (polyfills.1ea585f….bundle.js:37) at e [as constructor] (vendor.b857c3e….bundle.js:260) at e [as constructor] (vendor.b857c3e….bundle.js:752) at new e (vendor.b857c3e….bundle.js:752) at t._throwOrNull (vendor.b857c3e….bundle.js:1121) at t._getByKeyDefault (vendor.b857c3e….bundle.js:1121) at t._getByKey (vendor.b857c3e….bundle.js:1121) at t.get (vendor.b857c3e….bundle.js:1121) at e.get (vendor.b857c3e….bundle.js:456) at e.t.injectorGet (vendor.b857c3e….bundle.js:127) at e.createInternal (main.6bd317a….bundle.js:2) at e.t.createHostView (vendor.b857c3e….bundle.js:127) at t.create (vendor.b857c3e….bundle.js:78) at e.bootstrap (vendor.b857c3e….bundle.js:246) at vendor.b857c3e….bundle.js:246 t.handleError @ vendor.b857c3e….bundle.js:435 vendor.b857c3e….bundle.js:435 EXCEPTION: Uncaught (in promise): Error: DI Error Error: DI Error at e.d (https://scottschafer.github.io/BowlBlaster/polyfills.1ea585f55bc1325fd989.bundle.js:37:2213) at e [as constructor] (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:260:508) at e [as constructor] (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:752:228) at new e (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:752:555) at t._throwOrNull (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:1121:2766) at t._getByKeyDefault (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:1121:3104) at t._getByKey (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:1121:2485) at t.get (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:1121:848) at e.get (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:456:1144) at e.t.injectorGet (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:127:1750) at e.createInternal (https://scottschafer.github.io/BowlBlaster/main.6bd317a007068db26aa0.bundle.js:2:2039) at e.t.createHostView (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:127:1288) at t.create (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:78:1949) at e.bootstrap (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:246:4321) at https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:246:2567 t.handleError @ vendor.b857c3e….bundle.js:435 vendor.b857c3e….bundle.js:435 ORIGINAL STACKTRACE: t.handleError @ vendor.b857c3e….bundle.js:435 vendor.b857c3e….bundle.js:435 Error: Uncaught (in promise): Error: DI Error Error: DI Error at e.d (polyfills.1ea585f….bundle.js:37) at e [as constructor] (vendor.b857c3e….bundle.js:260) at e [as constructor] (vendor.b857c3e….bundle.js:752) at new e (vendor.b857c3e….bundle.js:752) at t._throwOrNull (vendor.b857c3e….bundle.js:1121) at t._getByKeyDefault (vendor.b857c3e….bundle.js:1121) at t._getByKey (vendor.b857c3e….bundle.js:1121) at t.get (vendor.b857c3e….bundle.js:1121) at e.get (vendor.b857c3e….bundle.js:456) at e.t.injectorGet (vendor.b857c3e….bundle.js:127) at e.createInternal (main.6bd317a….bundle.js:2) at e.t.createHostView (vendor.b857c3e….bundle.js:127) at t.create (vendor.b857c3e….bundle.js:78) at e.bootstrap (vendor.b857c3e….bundle.js:246) at vendor.b857c3e….bundle.js:246 at d (polyfills.1ea585f….bundle.js:37) at f (polyfills.1ea585f….bundle.js:37) at polyfills.1ea585f….bundle.js:37 at t.invokeTask (polyfills.1ea585f….bundle.js:37) at Object.onInvokeTask (vendor.b857c3e….bundle.js:197) at t.invokeTask (polyfills.1ea585f….bundle.js:37) at e.runTask (polyfills.1ea585f….bundle.js:37) at i (polyfills.1ea585f….bundle.js:37) t.handleError @ vendor.b857c3e….bundle.js:435 polyfills.1ea585f….bundle.js:37 Unhandled Promise rejection: No provider for t! ; Zone: angular ; Task: Promise.then ; Value: e Error: DI Error at e.d (https://scottschafer.github.io/BowlBlaster/polyfills.1ea585f55bc1325fd989.bundle.js:37:2213) at e [as constructor] (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:260:508) at e [as constructor] (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:752:228) at new e (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:752:555) at t._throwOrNull (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:1121:2766) at t._getByKeyDefault (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:1121:3104) at t._getByKey (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:1121:2485) at t.get (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:1121:848) at e.get (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:456:1144) at e.t.injectorGet (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:127:1750) at e.createInternal (https://scottschafer.github.io/BowlBlaster/main.6bd317a007068db26aa0.bundle.js:2:2039) at e.t.createHostView (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:127:1288) at t.create (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:78:1949) at e.bootstrap (https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:246:4321) at https://scottschafer.github.io/BowlBlaster/vendor.b857c3eb223ff6ce7021.bundle.js:246:2567 o @ polyfills.1ea585f….bundle.js:37 polyfills.1ea585f….bundle.js:37 d
Also having the same issue. Had it with Beta 31 too.
BTW, I tried downgrading to an earlier version of the CLI but the problem persists: @angular/cli: 1.0.0-beta.29 node: 6.9.5 os: darwin x64 @angular/common: 2.4.7 @angular/compiler: 2.4.7 @angular/core: 2.4.7 @angular/forms: 2.4.7 @angular/http: 2.4.7 @angular/platform-browser: 2.4.7 @angular/platform-browser-dynamic: 2.4.7 @angular/router: 3.4.7 @angular/cli: 1.0.0-beta.29 @angular/compiler-cli: 2.4.7
same issue
@angular/cli: 1.0.0-beta.32.3 node: 7.3.0 os: darwin x64
having the same issue
@angular/cli": "1.0.0-beta.32.3 node: v6.9.2 os: Window10 x64
Having the same issue.
@angular/cli": "1.0.0-beta.32.3 node: v7.5.0 os: macOS Sierra
We are also having this issue on Windows 10 with the --prod build flag (Node 6.9.5, @angular/cli 1.0.0-beta.30). It worked perfectly until we added a new node module (used npm install to add angular2-cookie) to the project.
The dev build still works, but with the production build we get the "EXCEPTION: No provider for t!" error. It looks like "t" might be a minified call to the new module- maybe it's not making it into the bundle? Further down the error we get:
"at t.get [as _CookieService_58] (main.6965705….bundle.js:4)"
CookieService is what we set up to manage the new node module we added.
Yes, I was also using https://www.npmjs.com/package/angular2-cookie. I removed it from my project and now the distribution build https://scottschafer.github.io//BowlBlaster// works.
On Wed, Feb 22, 2017 at 10:33 AM, Joseph Driscoll [email protected] wrote:
We are also having this issue on Windows 10 with the --prod build flag (Node 6.9.5, @angular/cli 1.0.0-beta.30). It worked perfectly until we added a new node module (used npm install to add angular2-cookie) to the project.
The dev build still works, but with the production build we get the "EXCEPTION: No provider for t!" error. It looks like "t" might be a minified call to the new module- maybe it's not making it into the bundle? Further down the error we get:
"at t.get [as _CookieService_58] (main.6965705….bundle.js:4)"
CookieService is what we set up to manage the new node module we added.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/4752#issuecomment-281759184, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5RaW82G4LnnfFGtnnGz7RInDBYJZdaks5rfH95gaJpZM4MDSet .
Not an issue with the CLI. Take a look here: https://github.com/salemdar/angular2-cookie/issues/37.
Thanks @ReidBraswell! The advice on that issue did work to get angular2-cookie working for our project.
Thanks @ReidBraswell ! The advice on that issue did work for me as well!
I'm still not sure exactly where the issue is, but it does seem like a problem to me when code runs fine in development but blows up cryptically in production. Even though there's a workaround, this feels like a bug to me.
@scottschafer the CLI for prod not uses AOT compilation not JIT, and with Angular 2.4.x a few things changed with the compilation process. angular2-cookie has not updated for compatibility with the Angular changes. That's how I understand it.
Closing as per @ReidBraswell's comment https://github.com/angular/angular-cli/issues/4752#issuecomment-281791994
BTW, for anyone who finds this, switch to https://github.com/salemdar/ngx-cookie it replaces angular2-cookie.
FYI - In my case this problem was caused by angular2-logger. See https://stackoverflow.com/a/43410786/156477 for the fix.
I don't know why this is considered a bug with just the package and not with the system. The point of using typescript is to catch stuff earlier, ie at compile time rather than run time. This is a runtime bug on production builds only - the worst place to trying to track it down. The angular2-cookie package isn't the only one doing it. I have an app currently doing this and I can't find the offender for the life of me as there are 50 some odd providers.
It seems to me that the optimizations of --aot are too aggressive if otherwise valid code is now broken.
i had the same issue with angualr2 cookie but after moving to ngx-cookie the issue was resolved.
i have the same issue but i don't work with cookie. I agree with bmansfie and I wish to know how deal with it
Please check: https://github.com/angular/angular/issues/19219
sorry but I didn't understand what I should downgrade? angular or angular compiler?