chovy
chovy

Reputation: 75666

Uncaught AssertionError: path must be a string error in Require.js

I'm getting the following error in my simple example using node-webkit:

Uncaught AssertionError: path must be a string

index.html

//base.js

require(["test"], function(test) {
    test.init();
});

//test.js

define(function(){
   window.c = window.console;
   return {
       init: function(){
           c.log('test.init');
       },

       destroy: function(){
           c.log('test.destroy');
       }
   }
});

Upvotes: 7

Views: 6626

Answers (2)

chovy
chovy

Reputation: 75666

Looks like the new version of RequireJS has a function called: requirejs() in addition to require() to avoid conflicts with node's require().

Upvotes: 7

chovy
chovy

Reputation: 75666

node provides its own require() so I had to make a copy of it window.requireNode and then add it back in the base.js callback:

<script>
    window.requireNode = window.require;
    window.require = undefined;
</script>

<script data-main="js/base" src="/bower_components/requirejs/require.js"></script>


require(["test"], function(test) {
    window.require = window.requireNode;
    test.init();
});

Upvotes: 4

Related Questions