I have set up AngularJs and jQuery using RequireJs within a nodeJs framework.
This is my main.js setup
require.config({
paths: {
angular: 'vendor/angular.min',
bootstrap: 'vendor/twitter/bootstrap',
jquery: 'vendor/jquery-1.9.0.min',
domReady: 'vendor/require/domReady',
underscore: 'vendor/underscore.min'
},
shim: {
angular: {
deps: [ 'jquery' ],
exports: 'angular'
}
}
});
require([
'app',
'angular-boot'
], function() {
});
In my app.js file
define(['angular'], function (angular) {
return angular.module('MyApp', []);
})
and in the angular-boot.js file
define([ 'angular', 'domReady' ], function (angular, domReady) {
domReady(function() {
angular.bootstrap(document, ['MyApp']);
});
});
In my HTML file, I only have this line to declare and use requirejs. I'm not using ng-ap or any other library.
<script data-main="js/main" src="js/require.js"></script>
Sometimes my code runs without issues, but other times I encounter this error:
Uncaught Error: No module: MyApp
If you have any insights or suggestions on how to resolve this issue, please let me know. Thank you very much.