0

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

Luis Valencia
  • 32,619
  • 93
  • 286
  • 506

1 Answers1

1

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.

Vishwanath
  • 6,284
  • 4
  • 38
  • 57
  • I added shell.js in the question, the original one, if I remove /durandal from define, then I get an even worse error. Uncaught TypeError: undefined is not a function (on the viewlocator line apparently) – Luis Valencia Aug 12 '14 at 12:48
  • Can you check this question see it is of any help to you http://stackoverflow.com/questions/16677596/durandal-routing-issue I dont have much idea about durandal... – Vishwanath Aug 12 '14 at 12:57