简体   繁体   中英

ERROR Error: Uncaught (in promise): Error: No provider for Boolean

I am dealing with an Angular 4 application written by my predecessor. The application now builds and runs, but after loading, I am getting this in the browser's console:

core.es5.js:1020 ERROR Error: Uncaught (in promise): Error: No provider for Boolean!
Error: No provider for Boolean!
    at injectionError (core.es5.js:1169)
    at noProviderError (core.es5.js:1207)
    at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_._throwOrNull (core.es5.js:2649)
    at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_._getByKeyDefault (core.es5.js:2688)
    at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_._getByKey (core.es5.js:2620)
    at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_.get (core.es5.js:2489)
    at resolveNgModuleDep (core.es5.js:9492)
    at _createClass (core.es5.js:9537)
    at _createProviderInstance$1 (core.es5.js:9503)
    at resolveNgModuleDep (core.es5.js:9488)
    at resolvePromise (zone.js:831)
    at resolvePromise (zone.js:788)
    at zone.js:892
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Object.onInvokeTask (core.es5.js:3881)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
    at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (zone.js:195)
    at drainMicroTaskQueue (zone.js:601)
defaultErrorLogger  @   core.es5.js:1020
webpackJsonp.../../../core/@angular/core.es5.js.ErrorHandler.handleError    @   core.es5.js:1080
next    @   core.es5.js:4503
schedulerFn @   core.es5.js:3635
webpackJsonp.../../../../rxjs/Subscriber.js.SafeSubscriber.__tryOrUnsub @   Subscriber.js:242
webpackJsonp.../../../../rxjs/Subscriber.js.SafeSubscriber.next @   Subscriber.js:189
webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber._next    @   Subscriber.js:129
webpackJsonp.../../../../rxjs/Subscriber.js.Subscriber.next @   Subscriber.js:93
webpackJsonp.../../../../rxjs/Subject.js.Subject.next   @   Subject.js:55
webpackJsonp.../../../core/@angular/core.es5.js.EventEmitter.emit   @   core.es5.js:3621
(anonymous) @   core.es5.js:3912
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke   @   zone.js:391
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.run  @   zone.js:150
webpackJsonp.../../../core/@angular/core.es5.js.NgZone.runOutsideAngular    @   core.es5.js:3844
onHandleError   @   core.es5.js:3912
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.handleError  @   zone.js:395
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runGuarded   @   zone.js:164
_loop_1 @   zone.js:694
api.microtaskDrainDone  @   zone.js:703
drainMicroTaskQueue @   zone.js:608
Promise.then (async)        
scheduleMicroTask   @   zone.js:584
webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.scheduleTask @   zone.js:413
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.scheduleTask @   zone.js:238
webpackJsonp.../../../../zone.js/dist/zone.js.Zone.scheduleMicroTask    @   zone.js:258
scheduleResolveOrReject @   zone.js:879
ZoneAwarePromise.then   @   zone.js:1012
webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_._bootstrapModuleWithZone   @   core.es5.js:4537
webpackJsonp.../../../core/@angular/core.es5.js.PlatformRef_.bootstrapModule    @   core.es5.js:4522
../../../../../src/main.ts  @   main.ts:11
__webpack_require__ @   bootstrap 5216c4c…:54
0   @   main.bundle.js:8832
__webpack_require__ @   bootstrap 5216c4c…:54
webpackJsonpCallback    @   bootstrap 5216c4c…:25
(anonymous) @   main.bundle.js:1

I have tried grepping from the project's root for Boolean , thinking it might have been a typo in a constructor somewhere. But grep cannot find a single hit.

The trace points to either core.es5.js or zone.js but nowhere to my application code so I don't really know where to start looking.

How can I get to the bottom of this and find where the error is?

Aaaaaaand it was just that... A boolean injected in a component's constructor. I just had missed it because I looked at the code too much and it was boolean not Boolean .

You need to look for Promise in the code that returns a boolean value. Write something like:

find . -type f|xargs grep --color Promise

Then change the value to something else

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM