Select the library to load by its path. Note that the search context for
path is not the directory which contains the file that is executing,
rather the file itself. So, if file
/foo.js is executed, and you want to
load the library
/bar.js, than you have to require
Currently, there is no central location for finding global libraries, thus
path must start with one of
File extensions must be explicitely provided. If
/foo.js is executing, and
you want to load
/foo.js/bar.js, then require it by
./bar.js, not just
Requiring a module allows you to build libraries (modules) and reuse them across your applications. The CommonJS 1.1 specification is implemented.
The following variables are injected in the required executing context:
module exports require
response are not
available. The callee must pass them in for use.
Modules MUST NOT define variables on the global scope.
var when defining them.)
Publishing a function directly via module.exports.
Publishing a function via returning it.
Publish multiple functions.
Nested require() with absolute path.
Nested require() with relative path.
Example for using module.id.
Example for using module.file.
Require fails: no such file.
Catching a require that fails.
Required code does not have access to response object.
Required code does not have access to request object.
Required code does not have access to f object.
Required code does not have access to context object.
Required code does not have access to app object.