Some knowledge about the Node.js module

An object module is run in the Node js script environment, module automatically added, and the system will function to another function package

E.g:

var module = {
    id: '.',
    exports: {}
};
var load = function (exports, module) {
  //自定义函数开始 function customFunction { console.log('Hello, ' + name + '!'); } module.exports = customFunction; // 自定义函数结束
   return module.exports; 
};
var exported = load(module.exports, module);

// 保存module:
save(module, exported);

Note: In addition to the time code block code is added in vitro red js script running in the Node automatically added to the environment

 

Attribute object module comprising:

Module {
  id: String,
  exports: Object,
  parent: Object,
  filename: String,
  loaded: Boolean,
  children: Array,
  paths: Array

}

 

Guess you like

Origin www.cnblogs.com/hros/p/10990551.html