nodejs4-Modules and Packages

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.