错误错误:未捕获(承诺):错误:没有布尔值提供程序

时间:2020-01-13 12:07:25

标签: angular

我正在处理我的前任编写的Angular 4应用程序。该应用程序现在可以构建并运行,但是在加载后,我正在浏览器的控制台中找到它:

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

我尝试从项目的根目录为Boolean进行grepping,认为这可能是某个构造函数中的错字。但是grep无法找到任何匹配。

跟踪指向core.es5.js或zone.js,但没有指向我的应用程序代码,因此我真的不知道从哪里开始寻找。

我该怎么做才能找到错误所在?

2 个答案:

答案 0 :(得分:1)

Aaaaaa就是这样……将布尔值注入组件的构造函数中。我只是想念它,因为我看了太多的代码,发现它是boolean而不是Boolean

答案 1 :(得分:0)

您需要在返回布尔值的代码中寻找Promise。像这样写:

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

然后将值更改为其他内容