Search code examples
requirejsgruntjsalmond

Requirejs Gruntfile cannot locate almond


i'm trying to use almond.js in grunt to combine my files into on .js and uglify it. My configuration in grunt is like this:

requirejs: {
                compile: {
                    options: {
                        baseURL: "www/js/lib",
                        mainConfigFile: 'www/js/main.js',
                        name: '../../../node_modules/almond/almond',
                        include: '../main',
                        out:'../target/app.min.js',
                        findNestedDependencies: true,
                        optimize: 'uglify',
                    }
                }
            },

my main.js is this:

require.config({
    baseUrl: "js/lib",

    paths: {
        app: '../app',
        tpl: '../tpl'
    },

    shim: {
        'backbone': {
            deps: ['underscore', 'jquery'],
            exports: 'Backbone'
        },
        'underscore': {
            exports: '_'
        },
        'backbone-indexeddb': {
            deps: ['backbone', 'IndexedDBShim']
        },
        'IndexedDBShim': {
            deps: ['backbone']
        }
    }
});

If i try to run grunt requirejs i get an error: Error: Error: ERROR: module path does not exist: project/www/js/js/lib/../../../node_modules/almond/almond.js for module named: ../../../node_modules/almond/almond. Path is relative to: project at /project/node_modules/grunt-contrib-requirejs/node_modules/requirejs/bin/r.js:25964:35

which i do not understand, where does the second /js/ in the path come from? It does not exist in my file structure, i have my project folder set up like this

project
  gruntfile
  node_modules
     almond
        almond.js
  www
    index.html
    js
        app
        lib
        main.js

Solution

  • Oh, i'm configuring the baseurl twice, shouldn't do that. If i remove the baseurl parameter in the gruntfile it works fine.