RequireJS Paths Not Work
I'm new to RequireJS and trying to use it. I followed an example in RequireJS docs but there is some problem. I can load the jquery but not app/shell. Root |__index.html |__javas
Solution 1:
Because you have multiple folder levels, you have to set your baseUrl as the root of your application. If you want to use require(['jquery'])
instead of require(['libs/jquery'])
, you have to specify the "alias" of it in your configuration.
requirejs.config({
baseUrl:'javascripts',
paths:{
jquery: 'libs/jquery'
}
});
Solution 2:
Try adding your main.js file explicitly after your requirejs script tag:
<script src="javascripts/libs/require.js"></script>
<script src="javascripts/main.js"></script>
This will load your configuration file synchronously after loading requirejs thus making sure the paths are set before a module is called. Hope it helps.
Post a Comment for "RequireJS Paths Not Work"