Skip to main content

Posts

Showing posts with the label loading

Loading- Exporting Modules in Node.Js

Loading a module: In node you can load module either using the path to the module or giving name  of the module. require keyword is used to load  module in node. Its look for the file in given path to load module if the require module is not core node module. You can install third party module using NPM (Node Package Manger). It downloads from the global repository to your local machine. var module = require( 'module-name' ); The require function returns an object that represent the module which have exported. It can be any javascript data type. It could be function, an array, any javascript object. Exporting a module: The CommonJs Module system is use to share the object or properties in node.js. Since Javaascript runs program in global scope. CommonJs Module is one of the best way for creating and sharing namespace in the javascript environment. Here below given an example to export a function in node.js. //person.js /** * Created by deepak.m.shrma@g...