Answers for "module wrapper function"

0

module wrapper function

Before a module's code is executed, Node.js will wrap it with a function wrapper that looks like the following:

(function(exports, require, module, __filename, __dirname) {
// Module code actually lives in here
});

By doing this, Node.js achieves a few things:

    It keeps top-level variables (defined with var, const or let) scoped to the module rather than the global object.
    It helps to provide some global-looking variables that are actually specific to the module, such as:
        The module and exports objects that the implementor can use to export values from the module.
        The convenience variables __filename and __dirname, containing the module's absolute filename and directory path.
Posted by: Guest on December-04-2020
0

npm can i use my modules without specifying the path

npm install --save ../path/to/mymodule
Posted by: Guest on October-22-2020

Browse Popular Code Answers by Language