如何找到包含错误的文件?
问题描述:
hy。我刚刚将我的应用程序更新为角度4.4.3和最新的角度材质。之后万吨的错误,现在我只有一次,但看起来有点混乱,因为这是很难理解什么是文件错误的名称在 我得到错误:如何找到包含错误的文件?
(SystemJS) Invalid provider - only instances of Provider and Type are allowed, got: [object Object]
Error: Invalid provider - only instances of Provider and Type are allowed, got: [object Object]
at invalidProviderError (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:1317:12)
at eval (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2118:19)
at Array.forEach (<anonymous>)
at _normalizeProviders (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2107:15)
at eval (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2115:13)
at Array.forEach (<anonymous>)
at _normalizeProviders (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2107:15)
at resolveReflectiveProviders (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2058:39)
at Function.ReflectiveInjector.resolve (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2287:16)
at Function.ReflectiveInjector.resolveAndCreate (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2319:79)
Evaluating http://localhost:8080/main.js
Error loading http://localhost:8080/main.js
at invalidProviderError (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:1317:12)
at eval (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2118:19)
at Array.forEach (<anonymous>)
at _normalizeProviders (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2107:15)
at eval (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2115:13)
at Array.forEach (<anonymous>)
at _normalizeProviders (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2107:15)
at resolveReflectiveProviders (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2058:39)
at Function.ReflectiveInjector.resolve (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2287:16)
at Function.ReflectiveInjector.resolveAndCreate (http://localhost:8080/node_modules/@angular/core/bundles/core.umd.js:2319:79)
Evaluating http://localhost:8080/main.js
Error loading http://localhost:8080/main.js
你能帮助我吗?错误在哪里? 我认为错误是在文件main.ts,但是只有短短的几行:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
有在AppModule
只有一个地方可以与providers
有关:
//changes languages that are set locally
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
@NgModule({
imports: [...,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [Http]
}
})
而且,还有其他地方在路由的其他组件文件中:
//used for listing json as treeview
import {
TreeviewI18n,
TreeviewItem, TreeviewConfig,
TreeviewHelper,
TreeviewComponent,
TreeviewEventParser, OrderDownlineTreeviewEventParser,
DownlineTreeviewItem
} from 'ngx-treeview';
@Component({
selector: '...',
templateUrl: '...',
providers: [HttpService,
{ provide: TreeviewEventParser, useClass: OrderDownlineTreeviewEventParser }
]
})
答
检查模块中的提供程序 - 您可能传递对象而不是提供程序类。
您遇到了无效提供程序的问题,此对象需要[对象对象]。但是添加你的代码,因为这不是一个答案,它只是调试错误所说的。 – 2017-10-09 07:55:48
问题出在你的AppModule里面,你在你的AppModules提供者数组中添加了一个错误的东西。发布你的'AppModule'的代码 – PierreDuc
@PierreDuc你能看到我更新的帖子吗? – AmoT