Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding the cause of "Unknown provider" errors

I'm getting the following error:

Error: [$injector:unpr] Unknown provider: nProvider <- n 

I know this is being caused by the minification process and I understand why. However is there an easy way to determine which file is actually causing the issue?

like image 216
Brett Postin Avatar asked Mar 05 '14 12:03

Brett Postin


1 Answers

Angular 1.3.x has an ng-strict-di directive that is placed on the same element as the ng-app directive. This element causes your app to throw an error whenever dependencies have not been annotated. While it still doesn't give you the line number of the offending code, it does give you the function with its parameters (i.e. function($scope, myServiceName)) which is hopefully unique enough that you can find it pretty quickly in a good code edit.

A good overview of the directive: ng-strict-di.

like image 132
ansorensen Avatar answered Sep 19 '22 23:09

ansorensen