Stuck with requirejs relative

I am having trouble to reference requirejs modules with relative path in the code and have them working with grunt-contrib-requirejs. Anyone has any clue on why this might happen?

File Structure:

src
 |
 --config.js
 |
 --js/
    |
    --package
         |
         ---project.js
         |
         ---utils.js

Requirejs config:

require.config({
    paths: {
        jquery: 'vendor/jquery-1.10.1.min'
    },
    shim: {
        jquery: []
    }
});

GruntFile:

  requirejs: {
    compile: {
      options: { 
        name : "./js/package/project",
        baseUrl: "src",
        mainConfigFile: "src/config.js",
        out: "build/js/project-build.js"
      }
    }
 }

In the project.js file, I am referencing a util.js as tryout,

var utilsObject = require('./js/package/utils.js');

When I run grunt requirejs, I get following error:

Error: ENOENT, no such file or directory
>> '{folder}/src/js/package/js/package/utils.js'
>> In module tree:
>>     js/package/project

You have set the baseUrl property to 'src' in your configuration. Try to remove it.

I have successfully used jQuery, RequireJS, grunt and grunt-contrib-requirejs to build my plugin. Maybe my setup can give you a hint?

链接地址: http://www.djcxy.com/p/93634.html

上一篇: grunt requirejs编译多个

下一篇: 与requirejs亲戚呆在一起