question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[AppInsightsService -> Router]: NullInjectorError: No provider for Router! (Angular 6)

See original GitHub issue

I am currently updating my insights service to angular 6 and after the update when i try to run ng serve i get the message

Error: StaticInjectorError(InsightsModule)[AppInsightsService -> Router]: 
  StaticInjectorError(Platform: core)[AppInsightsService -> Router]: 
    NullInjectorError: No provider for Router!
    at NullInjector.push../node_modules/@angular/core/fesm5/core.js.NullInjector.get (core.js:979)
    at resolveToken (core.js:1232)
    at tryResolveToken (core.js:1182)
    at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1077)
    at resolveToken (core.js:1232)
    at tryResolveToken (core.js:1182)
    at StaticInjector.push../node_modules/@angular/core/fesm5/core.js.StaticInjector.get (core.js:1077)
    at resolveNgModuleDep (core.js:9217)
    at _createClass (core.js:9264)
    at _createProviderInstance$1 (core.js:9234)

I’m not sure on what to do… everything was working fine with angular 5.2

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
Giocapetinicommented, Jun 29, 2018

@jondmcelroy i fixed that msg with RouterModule.forRoot([ { path: ‘’, component: AppInsightsService }, ]), on my app.module

2reactions
Giocapetinicommented, Jun 6, 2018

Sorry for it taking a while to reply Mark… i “fixed” this error msg using RouterModule.forRoot([ { path: '', component: AppInsightsService }, ]), in my imports insights.module.ts yes i was using the latest version for angular 6 (the original idea was to package the app insights in a service pre configured so that a component could be created and used in other projects by just importing the service, after i applied this and i try to bootstrap the module it gives me a new error msg. [ERROR in Tried to find bootstrap code, but could not. Specify either statically analyzable bootstrap code or pass in an entryModule to the plugins options.])

Read more comments on GitHub >

github_iconTop Results From Across the Web

No provider for router" while writing Karma-Jasmine unit test ...
You need to import RouterTestingModule when setting up the test module. /* tslint:disable:no-unused-variable */ import { async, ...
Read more >
How To Use Angular Modules (Nullinjectorerror: No Provider ...
NullInjectorError : No provider for TodoService! ??? Im creating a custom module and import it into 2 routing modules.
Read more >
NG0201: No provider for {token} found! - Angular
You see this error when you try to inject a service but have not declared a corresponding provider. A provider is a mapping...
Read more >
Angular How-to: Add Application Insights to an Angular SPA
Note: @types are automatically included and no additional dependency is needed. "dependencies": { "@microsoft/applicationinsights-web": ...
Read more >
No provider for router” while writing Karma-Jasmine unit test ...
component.spec.ts file: /* tslint:disable:no-unused-variable */ import { async, ComponentFixture, TestBed } from '@angular ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found