{ "source": "doc/api/globals.md", "globals": [ { "textRaw": "Class: Buffer", "type": "global", "name": "Buffer", "desc": "
Used to handle binary data. See the [buffer section][].
\n" }, { "textRaw": "clearImmediate(immediateObject)", "type": "global", "name": "clearImmediate", "desc": "[clearImmediate
] is described in the [timers][] section.
[clearInterval
] is described in the [timers][] section.
[clearTimeout
] is described in the [timers][] section.
Used to print to stdout and stderr. See the [console
][] section.
In browsers, the top-level scope is the global scope. That means that in\nbrowsers if you're in the global scope var something
will define a global\nvariable. In Node.js this is different. The top-level scope is not the global\nscope; var something
inside an Node.js module will be local to that module.
The process object. See the [process
object][] section.
[setImmediate
] is described in the [timers][] section.
[setInterval
] is described in the [timers][] section.
[setTimeout
] is described in the [timers][] section.
The name of the directory that the currently executing script resides in.
\nExample: running node example.js
from /Users/mjr
console.log(__dirname);\n// /Users/mjr\n
\n__dirname
isn't actually a global but rather local to each module.
For instance, given two modules: a
and b
, where b
is a dependency of\na
and there is a directory structure of:
/Users/mjr/app/a.js
/Users/mjr/app/node_modules/b/b.js
References to __dirname
within b.js
will return\n/Users/mjr/app/node_modules/b
while references to __dirname
within a.js
\nwill return /Users/mjr/app
.
The filename of the code being executed. This is the resolved absolute path\nof this code file. For a main program this is not necessarily the same\nfilename used in the command line. The value inside a module is the path\nto that module file.
\nExample: running node example.js
from /Users/mjr
console.log(__filename);\n// /Users/mjr/example.js\n
\n__filename
isn't actually a global but rather local to each module.
A reference to the module.exports
that is shorter to type.\nSee [module system documentation][] for details on when to use exports
and\nwhen to use module.exports
.
exports
isn't actually a global but rather local to each module.
See the [module system documentation][] for more information.
\n" }, { "textRaw": "module", "name": "module", "type": "var", "desc": "A reference to the current module. In particular\nmodule.exports
is used for defining what a module exports and makes\navailable through require()
.
module
isn't actually a global but rather local to each module.
See the [module system documentation][] for more information.
\n" }, { "textRaw": "require()", "type": "var", "name": "require", "desc": "To require modules. See the [Modules][] section. require
isn't actually a\nglobal but rather local to each module.
Modules are cached in this object when they are required. By deleting a key\nvalue from this object, the next require
will reload the module. Note that\nthis does not apply to [native addons][], for which reloading will result in an\nError.
Instruct require
on how to handle certain file extensions.
Process files with the extension .sjs
as .js
:
require.extensions['.sjs'] = require.extensions['.js'];\n
\nDeprecated In the past, this list has been used to load\nnon-JavaScript modules into Node.js by compiling them on-demand.\nHowever, in practice, there are much better ways to do this, such as\nloading modules via some other Node.js program, or compiling them to\nJavaScript ahead of time.
\nSince the Module system is locked, this feature will probably never go\naway. However, it may have subtle bugs and complexities that are best\nleft untouched.
\n" } ], "methods": [ { "textRaw": "require.resolve()", "type": "method", "name": "resolve", "desc": "Use the internal require()
machinery to look up the location of a module,\nbut rather than loading the module, just return the resolved filename.
These objects are available in all modules. Some of these objects aren't\nactually in the global scope but in the module scope - this will be noted.
\nThe objects listed here are specific to Node.js. There are a number of\n[built-in objects][] that are part of the JavaScript language itself, which are\nalso globally accessible.
\n", "globals": [ { "textRaw": "Class: Buffer", "type": "global", "name": "Buffer", "desc": "Used to handle binary data. See the [buffer section][].
\n" }, { "textRaw": "clearImmediate(immediateObject)", "type": "global", "name": "clearImmediate", "desc": "[clearImmediate
] is described in the [timers][] section.
[clearInterval
] is described in the [timers][] section.
[clearTimeout
] is described in the [timers][] section.
Used to print to stdout and stderr. See the [console
][] section.
In browsers, the top-level scope is the global scope. That means that in\nbrowsers if you're in the global scope var something
will define a global\nvariable. In Node.js this is different. The top-level scope is not the global\nscope; var something
inside an Node.js module will be local to that module.
The process object. See the [process
object][] section.
[setImmediate
] is described in the [timers][] section.
[setInterval
] is described in the [timers][] section.
[setTimeout
] is described in the [timers][] section.
The name of the directory that the currently executing script resides in.
\nExample: running node example.js
from /Users/mjr
console.log(__dirname);\n// /Users/mjr\n
\n__dirname
isn't actually a global but rather local to each module.
For instance, given two modules: a
and b
, where b
is a dependency of\na
and there is a directory structure of:
/Users/mjr/app/a.js
/Users/mjr/app/node_modules/b/b.js
References to __dirname
within b.js
will return\n/Users/mjr/app/node_modules/b
while references to __dirname
within a.js
\nwill return /Users/mjr/app
.
The filename of the code being executed. This is the resolved absolute path\nof this code file. For a main program this is not necessarily the same\nfilename used in the command line. The value inside a module is the path\nto that module file.
\nExample: running node example.js
from /Users/mjr
console.log(__filename);\n// /Users/mjr/example.js\n
\n__filename
isn't actually a global but rather local to each module.
A reference to the module.exports
that is shorter to type.\nSee [module system documentation][] for details on when to use exports
and\nwhen to use module.exports
.
exports
isn't actually a global but rather local to each module.
See the [module system documentation][] for more information.
\n" }, { "textRaw": "module", "name": "module", "type": "var", "desc": "A reference to the current module. In particular\nmodule.exports
is used for defining what a module exports and makes\navailable through require()
.
module
isn't actually a global but rather local to each module.
See the [module system documentation][] for more information.
\n" }, { "textRaw": "require()", "type": "var", "name": "require", "desc": "To require modules. See the [Modules][] section. require
isn't actually a\nglobal but rather local to each module.
Modules are cached in this object when they are required. By deleting a key\nvalue from this object, the next require
will reload the module. Note that\nthis does not apply to [native addons][], for which reloading will result in an\nError.
Instruct require
on how to handle certain file extensions.
Process files with the extension .sjs
as .js
:
require.extensions['.sjs'] = require.extensions['.js'];\n
\nDeprecated In the past, this list has been used to load\nnon-JavaScript modules into Node.js by compiling them on-demand.\nHowever, in practice, there are much better ways to do this, such as\nloading modules via some other Node.js program, or compiling them to\nJavaScript ahead of time.
\nSince the Module system is locked, this feature will probably never go\naway. However, it may have subtle bugs and complexities that are best\nleft untouched.
\n" } ], "methods": [ { "textRaw": "require.resolve()", "type": "method", "name": "resolve", "desc": "Use the internal require()
machinery to look up the location of a module,\nbut rather than loading the module, just return the resolved filename.