Modules and Packages:
The method of defining a module is similar to Sea.js, exposing an interface is also using exports. Call an interface is to use the Require note: In the introduction of the module when the sibling directory needs to add./, otherwise it will be an error in addition to the use of exports unexpected, As with Sea.js, you can also use module to expose the object module.exports=obj; Module properties: Module.id The ID of the current module, the main module is., the other is the module feels the path, can modify the Module.filename: The file name of the current module module.loaded: Loading is complete module.parent: Parent Module Object, Call the module object of the current module Module.children: Sub-module object, the directory of the other module object package that it calls itself: package to the interdependent module unified management, the function is encapsulated PS: If you are installing the package on Mac add sudo, example: WINDOWS:NPM Install mysqlmac:sudo npm install MySQL
nodejs4-Modules and Packages