-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Uncaught Error: [$injector:modulerr] Failed to instantiate module ng due to: Error: [$injector:unpr] Unknown provider: $compileProvider #9692
Comments
This means that some module is failing to load. The snippet that you have provided has the rest of the URL hidden so it is hard to see what is going on. |
@petebacondarwin Yes. This means that ng module is failing to load. :) And this happens while bootstrapping the app and ng module is first in a three element array: ng, I've looked at console and I've copied this error message from it. There's no other error. None. I hope you clicked that specific link and see that it doesn't give you any specific ideas about it. Unfortunately I've added this GitHub issue after exhausting other resources. I'm currently debugging angular code to get any further. |
Previously people had problems upgrading because their versions of angular and the various angular-* were mismatched. Can you make sure all you included angular files have the same version? |
@Narretz Yes they're all 1.3. Doublechecked it myself as well. :) |
Additional info while debugging Angular codeCode recursively calls Anyway. Constants seem to load fine, but when it comes to first directive, it has to get the
this calls the function getService(serviceName) {
if (cache.hasOwnProperty(serviceName)) {
if (cache[serviceName] === INSTANTIATING) {
throw $injectorMinErr('cdep', 'Circular dependency found: {0}', serviceName + ' <- ' + path.join(' <- '));
}
return cache[serviceName];
} else {
try {
path.unshift(serviceName);
cache[serviceName] = INSTANTIATING;
return cache[serviceName] = factory(serviceName); // <-- THIS LINE
} catch (err) {
if (cache[serviceName] === INSTANTIATING) {
delete cache[serviceName];
}
throw err;
} finally {
path.shift();
}
}
} Because it's the first time getting this service it wants to create it using a factory. but function () {
throw $injectorMinErr('unpr', "Unknown provider: {0}", path.join(' <- '));
} so it fails to load Hopefully this will be of some help troubleshooting this issue. |
This sounds like the problem. I am pretty sure that somewhere in there you have a directive or service that is not being loaded property. I would steer clear of monkey patching the To debug this, I would search for all the places where you do this and remove them to see that your application will bootstrap without it. Then add them back in a bit at a time until it fails. Then you should find your culprit. Alternatively put each monkey-patched component into its own module, for this debugging, then run again and the injector should be able to tell you which module failed to load. |
@petebacondarwin Did you even read my post? It's not other modules. Those directives don't require any additional modules. They're just defined in If this has been changed going from 1.2 to 1.3, then it should be documented in breaking changes document, shouldn't it? But I will just change these to load in my own module and test my specific page that uses my custom directives and see whether
|
Just mentioning that the actual breaking change is documented as such; both in the CHANGELOG and in the Developer Guide - Section: Migration. |
@Narretz So how are we suppose to write directives that should work on:
In which module should we be adding our common services (directives, filters, constants, values etc.) to satisfy these requirements? |
|
@petebacondarwin AD#1 This simply means that every page that uses some additional directives requires some Javascript code regardless whether it needs it or not. It should at least define the module that it's referring to. |
Hold on. How do you define these directives if not in JS?
|
only core directives are included if you bootstrap anonymously --- so if you need directives from some other module (like angular-ui), you need to define a module and give it dependencies on the third party modules that you want to use |
although you know, if we do detect anonymous bootstrapping, there's no reason we couldn't do Array.prototype.forEach.call(document.querySelectorAll('script'), function(script) {
var module = script.getAttribute('ng-module');
if (module) requires.push(module);
}); before bootstrapping anonymously --- but honestly that's just syntax sugar |
@caitp This last example of yours seems interesting. Can you provide a more elaborate example of your last example. Some actual code using this? |
@litera it's not in existing code, but I guess it would look like this: <html ng-app>
<head>
<script src="angular.js"></script>
<script src="angular-bootstrap-tpls.js" ng-module="ui.bootstrap"></script>
<script src="myApp.js" ng-module="myApp"></script>
<!-- anonymous bootstrapper will see these annotated script elements, and include
`ui.bootstrap` and `myApp` as modules when bootstrapping -->
</head>
<body>
<!-- my fancy app... -->
</body>
</html> This is just syntax sugar, though. |
@caitp I asked for a specific example (a JSFiddle or similar would be better) because I would like to know where There're also other downsides to this sugar:
And there's probably more to this. These are just from the top of my head. |
Dude,i have explained to you twice that the code does not actually work. The point is that it _could_work, by giving you a declarative way to declare dependencies. It's just an example of what it could do. The ng-module attribute would hint to the bootstrapper that those dependencies are needed. |
For what is worth, I am having the same issue. Did you ever figure out what the problem was? |
@acrodrig Yes. I had directives defined in the
then you'll have to create your own module and not use |
@Narretz thanks. I was getting the same error. :-) |
we should probably make it a static error to define the |
@caitp It would be helpful. |
+1 @caitp. |
Had the same problem, to get more info about the error call the bootstrap function with {debugInfoEnabled: true} like so: This will print out to the console what's the underlining module that fails to instantiate. |
If this happens, check your |
I got same error when I typed ui-bootstrap instead of ui.bootstrap in app.js |
i met the same error until i came here i can't solve it .but when i changed my ng-app="ng" to ng-app="myApp" it disappeared. maybe the culprit is the ng's keyword |
j'ai rencontré aussi le même problème j'ai verifié la version de l'angularJS et angular-route.min.js tous on la même version 1.6.9 aidez-moi svp! |
I've upgraded my app from AngularJS 1.2.x to 1.3. And now I'm getting this weird exception that I don't really know how to troubleshoot. It happens when it tries to bootstrap my app.
The text was updated successfully, but these errors were encountered: