Reputation: 1385
I am simply converting my small project into nodejs. But for some reason, the requireJS file - the one where you define the JS you will use in your project is not loading.
Here is my structure ...
the ng-app
is where I make the front-end for the site. I use gulp to process them into html and js and placed to ng-dist
Here is what my server.js file
var express = require('express');
var app = express();
app.use(express.static(__dirname + '/ng-dist'));
app.listen(3000);
When I go to my browser, it is rendered just as expected.
But it appears that my require.js
file is not being read as stated in the data-main
attribute.
Here is what require.js
file looks like.
require.config {
baseUrl :'app/'
paths : {
angular : '//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.min'
ngRoute : '//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-route.min'
ngAnimate : '//cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular-animate.min'
router : 'routes'
directives : 'directives/ref'
services : 'services/ref'
coreModule : 'config'
jQuery : '//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min'
uikit : '//cdnjs.cloudflare.com/ajax/libs/uikit/2.21.0/js/uikit'
}
shim: {
ngRoute:{
deps:['angular']
},
ngAnimate:{
deps:['ngRoute']
},
coreModule:{
deps:['ngAnimate']
},
uiKit:{
deps:['jQuery']
}
}
}
define ['coreModule'], ->
This is basically the same thing in my PHP project. I don't have an idea why require is not reading my require.js
file and load my scripts.
Upvotes: 2
Views: 981
Reputation: 10680
data-main is a RequireJS module to load. In Your case RequireJS try to load /require.js.js
. Remove the extension, and rename the file to app.js
(require.js
is ambiguous). Finally:
<script data-main="app"
src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.17/require.min.js">
</script>
Upvotes: 2