7

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');
       }
   }
});
4

2 に答える 2

4

node は独自の require() を提供するため、そのコピーを作成してからコールバックwindow.requireNodeに追加し直す必要がありました。base.js

<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();
});
于 2013-09-18T09:08:32.770 に答える