Nodejs Module System

Source: Internet
Author: User

To allow Nodejs files to be called each other, Nodejs provides a simple module system.

The module is the basic part of the Nodejs application, and the files and modules are one by one corresponding, in other words, a Nodejs file is a module, which may be JavaScript code, JSON or compiled c/s extension.

Create a module

Hello.js

Exports.world = function () {

Console.log (' Hello World ');

}

Main.js

var hello = require ('./hello ');

Hello.world ();

Require method

The Require method accepts the delivery of the following set of parameters

1, HTTP, FS, path, etc., the native module.

2./mod or./mod, relative path to the file module.

3,/pathtomodule/mod, Absolute path of the file module.

4, MoD, non-native module of the file module.

Nodejs Module System

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.