【发布时间】:2015-11-15 16:55:21
【问题描述】:
我有一个这样的文件夹结构。
-
include/index.js-
plugin/plugin.jshelper.js
地点:-
包含/index.js
//Function for mapping the path of "require" statement in the plugin.js file.
var mapRequirePath = function(){
var plugins = require('./plugin/plugin');
return plugins;
}
//Now call the plugins..
var plugin = mapRequirePath();
include/plugin/plugin.js
/*
I want all four require statements to point to the same file location '/include/plugin/helper.js'
i.e search in the same folder location for module irrespective of the '../' or '../../' present in the require statement
*/
var helper1 = require('./helper');
var helper2 = require('helper');
var helper3 = require('../../helper');
var helper4 = require('../helper');
我想在plugin.js 文件中映射require 的路径,这样所有的require 调用都应该在same directory only 中搜索它的模块。
【问题讨论】:
标签: javascript node.js