5 These objects are available in all modules. Some of these objects aren't
6 actually in the global scope but in the module scope - this will be noted.
14 Used to handle binary data. See the [buffer section][].
22 The name of the directory that the currently executing script resides in.
24 Example: running `node example.js` from `/Users/mjr`
27 console.log(__dirname);
31 `__dirname` isn't actually a global but rather local to each module.
39 The filename of the code being executed. This is the resolved absolute path
40 of this code file. For a main program this is not necessarily the same
41 filename used in the command line. The value inside a module is the path
44 Example: running `node example.js` from `/Users/mjr`
47 console.log(__filename);
48 // /Users/mjr/example.js
51 `__filename` isn't actually a global but rather local to each module.
53 ## clearImmediate(immediateObject)
57 [`clearImmediate`] is described in the [timers][] section.
59 ## clearInterval(intervalObject)
63 [`clearInterval`] is described in the [timers][] section.
65 ## clearTimeout(timeoutObject)
69 [`clearTimeout`] is described in the [timers][] section.
77 Used to print to stdout and stderr. See the [`console`][] section.
83 A reference to the `module.exports` that is shorter to type.
84 See [module system documentation][] for details on when to use `exports` and
85 when to use `module.exports`.
87 `exports` isn't actually a global but rather local to each module.
89 See the [module system documentation][] for more information.
95 * {Object} The global namespace object.
97 In browsers, the top-level scope is the global scope. That means that in
98 browsers if you're in the global scope `var something` will define a global
99 variable. In Node.js this is different. The top-level scope is not the global
100 scope; `var something` inside an Node.js module will be local to that module.
108 A reference to the current module. In particular
109 `module.exports` is used for defining what a module exports and makes
110 available through `require()`.
112 `module` isn't actually a global but rather local to each module.
114 See the [module system documentation][] for more information.
122 The process object. See the [`process` object][] section.
130 To require modules. See the [Modules][] section. `require` isn't actually a
131 global but rather local to each module.
137 Modules are cached in this object when they are required. By deleting a key
138 value from this object, the next `require` will reload the module.
140 ### require.extensions
142 Stability: 0 - Deprecated
146 Instruct `require` on how to handle certain file extensions.
148 Process files with the extension `.sjs` as `.js`:
151 require.extensions['.sjs'] = require.extensions['.js'];
154 **Deprecated** In the past, this list has been used to load
155 non-JavaScript modules into Node.js by compiling them on-demand.
156 However, in practice, there are much better ways to do this, such as
157 loading modules via some other Node.js program, or compiling them to
158 JavaScript ahead of time.
160 Since the Module system is locked, this feature will probably never go
161 away. However, it may have subtle bugs and complexities that are best
164 ### require.resolve()
166 Use the internal `require()` machinery to look up the location of a module,
167 but rather than loading the module, just return the resolved filename.
169 ## setImmediate(callback[, arg][, ...])
173 [`setImmediate`] is described in the [timers][] section.
175 ## setInterval(callback, delay[, arg][, ...])
179 [`setInterval`] is described in the [timers][] section.
181 ## setTimeout(callback, delay[, arg][, ...])
185 [`setTimeout`] is described in the [timers][] section.
187 [`console`]: console.html
188 [`process` object]: process.html#process_process
189 [buffer section]: buffer.html
190 [module system documentation]: modules.html
191 [Modules]: modules.html#modules_modules
192 [timers]: timers.html
193 [`clearImmediate`]: timers.html#timers_clearimmediate_immediateobject
194 [`clearInterval`]: timers.html#timers_clearinterval_intervalobject
195 [`clearTimeout`]: timers.html#timers_cleartimeout_timeoutobject
196 [`setImmediate`]: timers.html#timers_setimmediate_callback_arg
197 [`setInterval`]: timers.html#timers_setinterval_callback_delay_arg
198 [`setTimeout`]: timers.html#timers_settimeout_callback_delay_arg