How to use the module._nodeModulePaths function in module

To help you get started, we’ve selected a few module examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imba / imba / lib / register.js View on Github external
Module.prototype.load = function (filename){
			// console.log "getting to Module#load",filename
			this.filename = filename;
			this.paths = Module._nodeModulePaths(path.dirname(filename));
			var ext = findExtension(filename);
			Module._extensions[ext](this,filename);
			return this.loaded = true;
		};
	} else if(require.registerExtension) {
github pluginjs / pluginjs / tools / cli / scripts / utils / require-rc-file.js View on Github external
function requireFromString(code) {
  const paths = Module._nodeModulePaths(path.dirname(''))
  const parent = module.parent
  const m = new Module('', parent)
  m.filename = ''
  m.paths = paths

  m._compile(code, '')
  return m.exports
}
github yosbelms / cor / src / loader / node.js View on Github external
cor.Program.prototype.getExports = function(parent) {
    var mod, js = this.toJs();

    mod = new Module(this.filename, parent);

    mod.filename = this.filename;
    mod.paths    = Module._nodeModulePaths(nodePath.dirname(this.filename));
    mod.src      = js.src;
    mod.loaded   = true;
    mod._contextLoad = true;
    mod._compile(js.src, this.filename);

    return mod.exports || {};
}
github axmor / typecs / src / com.axmor.eclipse.typescript.core / lib / bridge / ts_1.0 / ets_io.js View on Github external
run: function (source, fileName) {
      log.debug('io.run:' + fileName);
      require.main.fileName = fileName;
      require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(fileName)));
      require.main._compile(source, fileName);
    },
github imba / imba / register.js View on Github external
Module.prototype.load = function (filename){
		this.filename = filename;
		this.paths = Module._nodeModulePaths(path.dirname(filename));
		var ext = findExtension(filename);
		Module._extensions[ext](this,filename);
		return this.loaded = true;
	};

module

Generate the minimal skeleton/boilerplate for a new Node.js module.

MIT
Latest version published 9 years ago

Package Health Score

41 / 100
Full package analysis