1

While the app works in debug mode, when release mode switches on .NET bundles, I get the Unknown Provider error. The problem is there many sources (Bootstrap UI and other third-party controls besides application scripts). I fixed a couple of obvious initializers, but this error seems to refer to minified code, generic names:

http://errors.angularjs.org/1.2.21/$injector/unpr?p0=nProvider%20%3C-%20n

How do you troubleshoot something like that?

Mark Meyerovich
  • 193
  • 3
  • 9
  • 1
    You're probably missing the annotation for an inject-able somewhere. Thus angular is complaining that it can't find `n` a minified service name. Maybe try [ng-annotate](https://github.com/olov/ng-annotate) – calebboyd Nov 10 '14 at 23:18
  • The error link seems trunkated, couldn't you have the full string? otherwise you should try to execute the same code with the non minimized version of angularjs: you will have an explicit error instead of a link. – floribon Nov 10 '14 at 23:31
  • Yup use unminified source while developing/debugging can switch to minified source for release – shaunhusain Nov 10 '14 at 23:52
  • @shaunhusain, the whole problem is there is no error in debug mode - when code is not minified, angular is able to find service or whatever it's looking for. – Mark Meyerovich Nov 11 '14 at 15:09
  • @floribon: the link is complete, at least as it shows up in console. There is no error in non-minified version. http://errors.angularjs.org/1.2.21/$injector/unpr?p0=nProvider%20%3C-%20n – Mark Meyerovich Nov 11 '14 at 15:15

1 Answers1

1

The way to figure out the problem was to exclude one script file at a time from minification and to see whether the error goes away. The error was actually similar to the one in the question on unknown provider "aProvider <- a" error.

In my case there were several errors. The main one was due to the modal dialog controller, similar to the discussion about injecting modal controller dependencies. However it would only occur with minified code.

The suggestion to provide the controller in the modal options as a string did not work for me. But declaring controller with its dependencies did the trick:

var ModalInstanceCtrl = ['$scope', '$modalInstance', 'items', 
           function ($scope, $modalInstance, items) { ... }
Community
  • 1
  • 1
Mark Meyerovich
  • 193
  • 3
  • 9
  • Usually this error: /unpr?p0=nProvider%20%3C-%20n is due to fact that when minimizing the file a parameter was renamed to "n". Angular does not know of any dependency "n", so the errors is raised. A quick way to address this is to look for all declaration of modules where dependencies are not explicitly defined in an array. This is often the root cause. for more information, take a look at this: http://www.ozkary.com/2015/11/angularjs-minimized-file-unknown-provider.html – ozkary Nov 18 '15 at 01:37