Reputation: 33978
I am trying to use the durandal router, but I have these 2 errors on my console:
Uncaught Error: Script error for: durandal/router
and of course this: Failed to load resource: the server responded with a status of 404 (Not Found)
which is very self explanatory I know, but I dont find any error on the code, or the files structure.
requirejs.config({
paths: {
'text': '../Scripts/text',
'durandal': '../Scripts/durandal',
'plugins': '../Scripts/durandal/plugins',
'transitions': '../Scripts/durandal/transitions'
}
});
define('jquery', [], function () { return jQuery; });
define('knockout', [], function () { return ko; });
define(['durandal/system', 'durandal/app', 'durandal/viewLocator', 'durandal/plugins/router', 'services/logger'], function (system, app, viewLocator, router, logger) {
app.title = 'My App';
//specify which plugins to install and their configuration
app.configurePlugins({
router: true,
dialog: true,
widget: {
kinds: ['expander']
}
});
system.debug(true);
app.start().then(function () {
router.useConvention();
viewLocator.useConvention();
app.setRoot('viewmodels/shell');
router.handleInvalidRoute = function (route, params) {
logger.logError('No route found', route, 'main', true);
};
});
});
shell.js
define(['durandal/system', 'services/logger', 'durandal/plugins/router','config'],
function(system,logger, router, config) {
var shell ={
activate: activate,
router: router
};
return shell;
function activate(){
logger.log('CodeCamper Jumpstart Loaded!',
null,
system.getModuleId(shell),
true)
router.map(config.routes);
return router.activate(config.startModule);
}
}
);
vs structure
http://screencast.com/t/Occ6BICg
Upvotes: 0
Views: 1597
Reputation: 6004
Try asking for router using only plugins path declaration.
define(['durandal/system', 'durandal/app', 'durandal/viewLocator', 'plugins/router', 'services/logger'], function (system, app, viewLocator, router, logger) {
//Your code here
});
I am guessing this is happening because in your require you have durandal and plugins both appended to router. Since both of them are in the path configuration they cause the resolved path to be incorrect.
Upvotes: 1