StaticInjectorError [RendererFactory2]:NullInjectorError:RendererFactory2没有提供程序

时间:2019-07-06 10:37:47

标签: angular

[在此处输入图像描述] [1]在尝试将apollo客户端安装到我的应用程序之前,我没有任何问题。然后我不得不将我的角度升级到5.0.0,但之前是4.4.6。 我一直在寻找代码中的错误,但它没有给我参考。

这是错误的完整日志:

  

core.js:1350错误错误:未捕获(承诺):错误:StaticInjectorError [RendererFactory2]:     StaticInjectorError [RendererFactory2]:       NullInjectorError:RendererFactory2没有提供程序!   错误:StaticInjectorError [RendererFactory2]:     StaticInjectorError [RendererFactory2]:       NullInjectorError:RendererFactory2没有提供程序!       
NullInjector.get(core.js:923)       
在resolveToken(core.js:1211)       
在tryResolveToken(core.js:1153)       
在StaticInjector.get(core.js:1024)       
在resolveToken(core.js:1211)       
在tryResolveToken(core.js:1153)       
在StaticInjector.get(core.js:1024)       
在resolveNgModuleDep(core.js:10584)       
在NgModuleRef
.get(core.js:11805)       
在resolveDep(core.js:12301)       
在resolvePromise(zone.js:852)       
在resolvePromise(zone.js:809)       
在eval(zone.js:913)       
在ZoneDelegate.invokeTask(zone.js:423)       
at Object.onInvokeTask(core.js:4617)       
在ZoneDelegate.invokeTask(zone.js:422)       
在Zone.runTask(zone.js:195)       
在排水微任务队列(zone.js:601)

  • app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import {RouterModule} from '@angular/router';

import {AppRoutes} from './app.routing';

import { AppComponent } from './app.component';
import { AdminComponent } from './layout/admin/admin.component';
import {ClickOutsideModule} from 'ng-click-outside';
import {SharedModule} from './shared/shared.module';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {BreadcrumbsComponent} from './layout/admin/breadcrumbs/breadcrumbs.component';
import {TitleComponent} from './layout/admin/title/title.component';
import {AuthComponent} from './layout/auth/auth.component';
import { HttpClientModule } from '@angular/common/http';
import { ApolloModule, APOLLO_OPTIONS } from 'apollo-angular';
import { HttpLinkModule, HttpLink } from 'apollo-angular-link-http';
import { InMemoryCache } from 'apollo-cache-inmemory';


@NgModule({
  declarations: [
    AppComponent,
    AdminComponent,
    BreadcrumbsComponent,
    TitleComponent,
    AuthComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    RouterModule.forRoot(AppRoutes),
    ClickOutsideModule,
    SharedModule,
    HttpClientModule,
    ApolloModule,
    HttpLinkModule
  ],
  providers: [{
    provide: APOLLO_OPTIONS,
    useFactory: vef,
    deps: [HttpLink]
  }],
  bootstrap: [AppComponent]
})
export class AppModule { }


export function vef(httpLink: HttpLink){
  return {
    cache: new InMemoryCache(),
    link: httpLink.create({
      uri: 'http://localhost:4001/graphql'
    })
  };
}

  • package.json:
{
  "name": "printingcider-admin",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --base-href /admin/",
    "build": "ng build --base-href /admin/",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "serve": "serve dist"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "^1.0.0-beta.6",
    "@angular/animations": "5.0.0",
    "@angular/common": "5.0.0",
    "@angular/compiler": "5.0.0",
    "@angular/core": "^5.0.0",
    "@angular/forms": "5.0.0",
    "@angular/http": "5.0.0",
    "@angular/platform-browser": "5.0.0",
    "@angular/platform-browser-dynamic": "5.0.0",
    "@angular/router": "5.0.0",
    "@ng-bootstrap/ng-bootstrap": "1.0.0-beta.5",
    "@nicky-lenaers/ngx-scroll-to": "0.4.0",
    "@swimlane/ngx-datatable": "9.3.0",
    "angular-froala-wysiwyg": "1.0.0",
    "angular-io-slimscroll": "2.3.3",
    "angular2-chartjs": "0.3.0",
    "angular2-datatable": "0.6.0",
    "angular2-material-datepicker": "^0.5.0",
    "angular2-notifications": "0.7.8",
    "angular2-wizard": "0.4.0",
    "apollo-angular": "1.6.0",
    "apollo-angular-link-http": "1.8.0",
    "apollo-cache-inmemory": "1.6.2",
    "apollo-client": "2.6.3",
    "apollo-link": "1.2.12",
    "bootstrap": "4.0.0-beta",
    "c3": "0.4.18",
    "core-js": "2.4.1",
    "css-animator": "2.1.1",
    "d3": "4.11.0",
    "famfamfam-flags": "1.0.0",
    "font-awesome": "4.7.0",
    "graphql": "14.4.2",
    "graphql-tag": "2.10.1",
    "jquery": "3.2.1",
    "jquery-sparkline": "2.4.0",
    "ng-click-outside": "2.4.1",
    "ng-select": "1.0.0-beta.6",
    "ng2-currency-mask": "4.3.4",
    "ng2-file-upload": "1.2.1",
    "ng2-google-charts": "3.2.0",
    "ng2-nvd3": "2.0.0",
    "ng2-toasty": "4.0.3",
    "ng2-ui-switch": "1.0.2",
    "ng2-validation": "4.2.0",
    "ngx-bootstrap": "1.9.3",
    "ngx-chips": "1.4.6",
    "ngx-color-picker": "4.4.0",
    "ngx-echarts": "1.2.4",
    "ngx-quill-editor": "2.2.2",
    "node-sass": "4.12.0",
    "peity": "3.2.1",
    "rxjs": "^6.5.2",
    "rxjs-compat": "^6.5.2",
    "screenfull": "3.3.1",
    "serve": "11.0.0",
    "squeezebox": "1.2.0",
    "sweetalert2": "6.10.3",
    "ti-icons": "0.1.2",
    "typescript": "^3.5.2",
    "zone.js": "^0.9.1"
  },
  "devDependencies": {
    "@angular/cli": "^1.7.4",
    "@angular/compiler-cli": "5.0.0",
    "@angular/language-service": "5.0.0",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.1.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.3.2",
    "webpack-bundle-analyzer": "2.9.0"
  }
}

0 个答案:

没有答案