简体   繁体   English

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

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

I am dealing with an Angular 4 application written by my predecessor.我正在处理由我的前任编写的 Angular 4 应用程序。 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.我曾尝试从项目的根目录搜索Boolean ,认为它可能是某个构造函数中的拼写错误。 But grep cannot find a single hit.但是 grep 找不到单个命中。

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.跟踪指向 core.es5.js 或 zone.js 但无处指向我的应用程序代码,所以我真的不知道从哪里开始寻找。

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. Aaaaaa 就是这样... 一个注入到组件构造函数中的布尔值。 I just had missed it because I looked at the code too much and it was boolean not Boolean .我只是错过了它,因为我看代码太多了,它是boolean而不是Boolean

You need to look for Promise in the code that returns a boolean value.您需要在返回布尔值的代码中查找 Promise。 Write something like:写一些类似的东西:

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

Then change the value to something else然后将值更改为其他值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获(在承诺中):错误:没有String的提供者 - Uncaught (in promise): Error: No provider for String 未发现(承诺中):错误:没有凭据提供者? - Uncaught (in promise): Error: No provider for Credentials? 未捕获(承诺):错误:没有 GooglePlus 的提供者 - Uncaught (in promise): Error: No provider for GooglePlus 错误:未捕获(承诺):[object Boolean] - Error: Uncaught (in promise): [object Boolean] 错误错误:未捕获(承诺中):错误:ActivatedRoute没有提供程序 - ERROR Error: Uncaught (in promise): Error: No provider for ActivatedRoute 错误:错误错误:未捕获(承诺):[对象布尔] - Error : ERROR Error: Uncaught (in promise): [object Boolean] 错误:未捕获(承诺):错误:ActivatedRoute没有提供程序 - Error: Uncaught (in promise): Error: No provider for ActivatedRoute Angular 2 No Provider或DI错误(未捕获(承诺):错误:No Provider…) - Angular 2 No Provider or DI error (Uncaught (in promise): Error: No provider …) 如何解决“错误:未捕获(承诺):错误:没有提供”Ionic 3中的错误 - How to solve “Error: Uncaught (in promise): Error: No provider for” error in Ionic 3 错误:未捕获(承诺):错误:没有服务提供程序-Angular 4.1.2 - Error: Uncaught (in promise): Error: No provider for Service - Angular 4.1.2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM