cjs icon indicating copy to clipboard operation
cjs copied to clipboard

Error: Explicit require of module is not allowed.

Open rally25rs opened this issue 10 years ago • 4 comments

I'm trying to put together the simplest example I can, and having a problem.

This is my main.js:

require.config({
    paths: {
        "amd-loader": "node_modules/amd-loader/amd-loader"
    }
});

require(["cjs!test"], function (test) {
    console.log(test.out);
});

And this is test.js:

exports.out="hi";

If I try to run r.js on main, I get:

Error: Error: Explicit require of module is not allowed.
In module tree:
    main
      cjs

Any idea why?

rally25rs avatar Nov 15 '14 13:11 rally25rs

This project hasn't been maintained for over a year so it may have drifted out of date with RequireJS updates. I have no idea of that error message - it was not in the previous versions of require.

I guess the issue happens on this line https://github.com/guybedford/amd-loader/blob/master/amd-loader.js#L30. If you work it out please let me know. Sorry I can't be of more help than this... perhaps consider using SystemJS.

guybedford avatar Nov 17 '14 13:11 guybedford

Thanks for the reply. While I was looking around on GitHub issues I also noticed that you have moved your efforts to the System plugin. It might be a good idea to make a note that the plugin is deprecated in favor of System on the RequireJS list of plugins on GitHub. Would save you from having to deal with people filing more issues :)

Thanks again!

-Jeff

On Nov 17, 2014, at 8:31 AM, Guy Bedford [email protected] wrote:

This project hasn't been maintained for over a year so it may have drifted out of date with RequireJS updates. I have no idea of that error message - it was not in the previous versions of require.

I guess the issue happens on this line https://github.com/guybedford/amd-loader/blob/master/amd-loader.js#L30 https://github.com/guybedford/amd-loader/blob/master/amd-loader.js#L30. If you work it out please let me know. Sorry I can't be of more help than this... perhaps consider using SystemJS.

— Reply to this email directly or view it on GitHub https://github.com/guybedford/cjs/issues/3#issuecomment-63304445.

rally25rs avatar Nov 17 '14 15:11 rally25rs

I don't see any require config path for cjs itself.

patkujawa-wf avatar Nov 17 '14 17:11 patkujawa-wf

For me the problem was that amd-loader is other plugin in bower/npm registry - amd-loader git://github.com/ajaxorg/node-amd-loader.git - if you installed amd-module via bower or npm it can be also your issue

temnoregg avatar Jul 10 '15 10:07 temnoregg