No provider for navcontroller ionic 3.5

Hello everyone, I just came back from vacation and I havent touched my code in two months. I had these error so I decided to upgrade to ionic 3.5 and resolve it afterwards. I don’t know exactly where my errors came from. This is the error I get.

Error: Uncaught (in promise): Error: No provider for NavController!
Error: No provider for NavController!
    at injectionError (http://localhost:8100/build/vendor.js:1852:86)
    at noProviderError (http://localhost:8100/build/vendor.js:1890:12)
    at ReflectiveInjector_._throwOrNull (http://localhost:8100/build/vendor.js:3391:19)
    at ReflectiveInjector_._getByKeyDefault (http://localhost:8100/build/vendor.js:3430:25)
    at ReflectiveInjector_._getByKey (http://localhost:8100/build/vendor.js:3362:25)
    at ReflectiveInjector_.get (http://localhost:8100/build/vendor.js:3231:21)
    at AppModuleInjector.get (ng:///AppModule/module.ngfactory.js:263:155)
    at AppModuleInjector.getInternal (ng:///AppModule/module.ngfactory.js:386:56)
    at AppModuleInjector.NgModuleInjector.get (http://localhost:8100/build/vendor.js:4198:44)
    at resolveDep (http://localhost:8100/build/vendor.js:11660:45)
    at c (http://localhost:8100/build/polyfills.js:3:13535)
    at Object.reject (http://localhost:8100/build/polyfills.js:3:12891)
    at Tab.NavControllerBase._fireError (http://localhost:8100/build/vendor.js:44257:16)
    at Tab.NavControllerBase._failed (http://localhost:8100/build/vendor.js:44245:14)
    at http://localhost:8100/build/vendor.js:44300:59
    at t.invoke (http://localhost:8100/build/polyfills.js:3:9283)
    at Object.onInvoke (http://localhost:8100/build/vendor.js:4770:37)
    at t.invoke (http://localhost:8100/build/polyfills.js:3:9223)
    at (http://localhost:8100/build/polyfills.js:3:4452)
    at http://localhost:8100/build/polyfills.js:3:14076

I came to the point where importing navcontroller in app.module.ts, but I dont know where to declare it. Maybe it’s because I switched PC and I missed an npm install. Anyone who knows what to do to make it work again?

I suspect you are trying to inject NavController in your app component. That won’t work, and you shouldn’t be trying to do that.

Just in case someone comes along looking for the answer on why you should not do that it is found in the docs:


What if you want to control navigation from your root app component? You can’t inject NavController because any components that are navigation controllers are children of the root component so they aren’t available to be injected.

By adding a reference variable to the ion-nav, you can use @ViewChild to get an instance of the Nav component, which is a navigation controller (it extends NavController):

1 Like