I am having some trouble importing my sub-module when using the AngularJS framework.
I have created the module and its dependencies, checked my import order and imported the js files in the index.html <script> tag.
When my server attempts to render my page I get a $injector:modulerr
The stack trace points at bower, however all my bower components are present.
I am unsure how to debug this issue.
I have the directory structure:
app.js
hmodule/
hmodule/helpermonkeys.js
hmodule/services/monkeymessageservice.js
hmodule/controllers/monkeycontroller.js
/app.js:
var centroApp = angular.module("centroApp", ['ngRoute', ..., 'ngWebSocket', 'helpermonkeys'])
/hmodule/hm.js
(function() {
'use strict';
angular.module('helpermonkeys', ['ngWebSocket', 'monkeyMessageService', 'monkeyController']);
})();
/hmodule/services/monkeymessageservice.js
(function() {
'use strict';
angular.module('helpermonkeys').factory('monkeyMessageService', ['ngWebSocket', monkeyMessageService]);
function monkeyMessageService($websocket) {
var messageService = {
connect: connect,
sendActuatorRequest: sendActuatorRequest,
sendDataRequest: sendDataRequest,
sendCommandRequest: sendCommandRequest,
messages: []
}
return messageService;
...
})();
/hmmodule/controllers/monekeycontroller.js
(function() {
'use strict';
angular.module('helpermonkeys').controller('monkeyController', ['$scope', 'monkeyMessageService', monkeyController]);
....
})();
index.html
<script src="/js/helpermonkeysmodule/helpermonkeys.js"></script>
<script src="/js/helpermonkeysmodule/services/monkeymessageservice.js"></script>
<script src="/js/helpermonkeysmodule/controllers/monkeycontroller.js"></script>
<script src="/js/app.js"></script>
Stack Trace
Failed to instantiate module centroApp due to:
Error: [$injector:modulerr] http://errors.angularjs.org/1.5.9/$injector/modulerr?p0=h...)
at https://localhost/bower_components/angular/angular.min.js:6:412
at https://localhost/bower_components/angular/angular.min.js:40:292
at q (https://localhost/bower_components/angular/angular.min.js:7:359)
at g (https://localhost/bower_components/angular/angular.min.js:39:382)
at https://localhost/bower_components/angular/angular.min.js:40:34
at q (https://localhost/bower_components/angular/angular.min.js:7:359)
at g (https://localhost/bower_components/angular/angular.min.js:39:382)
at eb (https://localhost/bower_components/angular/angular.min.js:43:382)
at c (https://localhost/bower_components/angular/angular.min.js:21:19)
at Ic (https://localhost/bower_components/angular/angular.min.js:21:332
Error URL:
https://docs.angularjs.org/error/$injector/modulerr?p0=helpermonkeys&p1=Error:%20%5B$injector:modulerr%5D%20http:%2F%2Ferrors.angularjs.org%2F1.5.9%2F$injector%2Fmodulerr%3Fp0%3DmonkeyMessageService%26p1%3DError%253A%2520%255B%2524injector%253Anomod%255D%2520http%253A%252F%252Ferrors.angularjs.org%252F1.5.9%252F%2524injector%252Fnomod%253Fp0%253DmonkeyMessageService%250A%2520%2520%2520%2520at%2520https%253A%252F%252Flocalhost%252Fbower_components%252Fangular%252Fangular.min.js%253A6%253A412%250A%2520%2520%2520%2520at%2520https%253A%252F%252Flocalhost%252Fbower_components%252Fangular%252Fangular.min.js%253A25%253A235%250A%2520%2520%2520%2520at%2520b%2520(https%253A%252F%252Flocalhost%252Fbower_components%252Fangular%252Fangular.min.js%253A24%253A282)%250A%2520%2520%2520%2520at%2520https%253A%252F%252Flocalhost%252Fbower_components%252Fangular%252Fangular.min.js%253A25%253A20%250A%2520%2520%2520%2520at%2520https%253A%252F%252Flocalhost%252Fbower_components%252Fangular%252Fangular.min.js%253A40%253A17%250A%2520%2520%2520%2520at%2520q%2520(https%253A%252F%252Flocalhost%252Fbower_components%252Fangular%252Fangular.min.js%253A7%253A359)%250A%2520%2520%2520%2520at%2520g%2520(https%253A%252F%252Flocalhost%252Fbower_components%252Fangular%252Fangular.min.js%253A39%253A382)%250A%2520%2520%2520%2520at%2520https%253A%252F%252Flocalhost%252Fbower_components%252Fangular%252Fangular.min.js%253A40%253A34%250A%2520%2520%2520%2520at%2520q%2520(https%253A%252F%252Flocalhost%252Fbower_components%252Fangular%252Fangular.min.js%253A7%253A359)%250A%2520%2520%2520%2520at%2520g%2520(https%253A%252F%252Flocalhost%252Fbower_components%252Fangular%252Fangular.min.js%253A39%253A382)%0A%20%20%20%20at%20https:%2F%2Flocalhost%2Fbower_components%2Fangular%2Fangular.min.js:6:412%0A%20%20%20%20at%20https:%2F%2Flocalhost%2Fbower_components%2Fangular%2Fangular.min.js:40:292%0A%20%20%20%20at%20q%20(https:%2F%2Flocalhost%2Fbower_components%2Fangular%2Fangular.min.js:7:359)%0A%20%20%20%20at%20g%20(https:%2F%2Flocalhost%2Fbower_components%2Fangular%2Fangular.min.js:39:382)%0A%20%20%20%20at%20https:%2F%2Flocalhost%2Fbower_components%2Fangular%2Fangular.min.js:40:34%0A%20%20%20%20at%20q%20(https:%2F%2Flocalhost%2Fbower_components%2Fangular%2Fangular.min.js:7:359)%0A%20%20%20%20at%20g%20(https:%2F%2Flocalhost%2Fbower_components%2Fangular%2Fangular.min.js:39:382)%0A%20%20%20%20at%20https:%2F%2Flocalhost%2Fbower_components%2Fangular%2Fangular.min.js:40:34%0A%20%20%20%20at%20q%20(https:%2F%2Flocalhost%2Fbower_components%2Fangular%2Fangular.min.js:7:359)%0A%20%20%20%20at%20g%20(https:%2F%2Flocalhost%2Fbower_components%2Fangular%2Fangular.min.js:39:382
Thanks to @charlietfl for pointing out the offending file can be found in the URL, I am going to investigate my Messaging service.
.... Can also be cause by a syntax errormonkeyMessageServicedoes not exist as a module in your application for some reason.