Prod Build throws Undefined Provider Error

When upgrading to Ionic 3 I am seeing an ‘Undefined provider’ error being thrown when doing a --prod build. Example

ionic build ios --prod

ngc started ...
[15:23:29]  ionic-app-script task: "build"
[15:23:29]  Error: Encountered undefined provider! Usually this means you have a circular 
dependencies (might be caused
        by using 'barrel' index.ts files.

I am using Ionic 3.0.0 and Ionic Native 3.4~

I tried to find a dependency that was circular but couldnt think of any other upgrades I had made other than making an ionic native upgrade.

2 Likes

I’m seeing the same thing when upgrading to 3.0.1 (from 2.3.0). Ionic serve and non-prod build works fine.

1 Like

Same here.

ionic build android --prod --release 

fails to build with above mentioned error.

Note, however, that a debug build with

ionic build android 

works as expected.

Package.json dependencies are the same as in a new project (which builds ok in prod).

There is an open issue about it https://github.com/driftyco/ionic-app-scripts/issues/885

On a side note, maybe this thread should be moved to ionic2 forum…

I had the same issue, on my case i removed “storage” from providers
@NgModule({
providers: [ storage, … ]
})
in app.module.ts

NOTE since @ionic/storage 2.x.x
we import
IonicStorageModule instead of storage

2 Likes

Yes! This was my case also. Many thanks @romeodenis5 !!

This works thanks a lot!!

In my case, there is no storage.still, it is giving this Encountered undefined provider Error.
Please help me in this case!!!