经过一番挫折,我终于决定requirejs
通过npm
. 但是,即使使用这个基本示例,它仍然无法正常工作。
define(function(require) {
var requirejs = require('node/node/lib/node_modules/npm/node_modules/requirejs/require');
requirejs.config({
//Pass the top-level main.js/index.js require
//function to requirejs so that node modules
//are loaded relative to the top-level JS file.
nodeRequire: require
});
requirejs(['http'],
function (http) {
// code here
});
});
错误:
TypeError: requirejs is undefined @ test.js:7
如果我用 just 替换长路径require
,我会得到:
TypeError: requirejs.config is not a function @ test.js:11