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`
26 console.log(__dirname);
29 `__dirname` isn't actually a global but rather local to each module.
37 The filename of the code being executed. This is the resolved absolute path
38 of this code file. For a main program this is not necessarily the same
39 filename used in the command line. The value inside a module is the path
42 Example: running `node example.js` from `/Users/mjr`
44 console.log(__filename);
45 // /Users/mjr/example.js
47 `__filename` isn't actually a global but rather local to each module.
51 Stop a timer that was previously created with `setInterval()`. The callback
56 The timer functions are global variables. See the [timers][] section.
60 Stop a timer that was previously created with `setTimeout()`. The callback will
69 Used to print to stdout and stderr. See the [console][] section.
75 A reference to the `module.exports` that is shorter to type.
76 See [module system documentation][] for details on when to use `exports` and
77 when to use `module.exports`.
79 `exports` isn't actually a global but rather local to each module.
81 See the [module system documentation][] for more information.
87 * {Object} The global namespace object.
89 In browsers, the top-level scope is the global scope. That means that in
90 browsers if you're in the global scope `var something` will define a global
91 variable. In Node.js this is different. The top-level scope is not the global
92 scope; `var something` inside an Node.js module will be local to that module.
100 A reference to the current module. In particular
101 `module.exports` is used for defining what a module exports and makes
102 available through `require()`.
104 `module` isn't actually a global but rather local to each module.
106 See the [module system documentation][] for more information.
114 The process object. See the [process object][] section.
122 To require modules. See the [Modules][] section. `require` isn't actually a
123 global but rather local to each module.
129 Modules are cached in this object when they are required. By deleting a key
130 value from this object, the next `require` will reload the module.
132 ### require.extensions
134 Stability: 0 - Deprecated
138 Instruct `require` on how to handle certain file extensions.
140 Process files with the extension `.sjs` as `.js`:
142 require.extensions['.sjs'] = require.extensions['.js'];
144 **Deprecated** In the past, this list has been used to load
145 non-JavaScript modules into Node.js by compiling them on-demand.
146 However, in practice, there are much better ways to do this, such as
147 loading modules via some other Node.js program, or compiling them to
148 JavaScript ahead of time.
150 Since the Module system is locked, this feature will probably never go
151 away. However, it may have subtle bugs and complexities that are best
154 ### require.resolve()
156 Use the internal `require()` machinery to look up the location of a module,
157 but rather than loading the module, just return the resolved filename.
159 ## setInterval(cb, ms)
161 Run callback `cb` repeatedly every `ms` milliseconds. Note that the actual
162 interval may vary, depending on external factors like OS timer granularity and
163 system load. It's never less than `ms` but it may be longer.
165 The interval must be in the range of 1-2,147,483,647 inclusive. If the value is
166 outside that range, it's changed to 1 millisecond. Broadly speaking, a timer
167 cannot span more than 24.8 days.
169 Returns an opaque value that represents the timer.
171 ## setTimeout(cb, ms)
173 Run callback `cb` after *at least* `ms` milliseconds. The actual delay depends
174 on external factors like OS timer granularity and system load.
176 The timeout must be in the range of 1-2,147,483,647 inclusive. If the value is
177 outside that range, it's changed to 1 millisecond. Broadly speaking, a timer
178 cannot span more than 24.8 days.
180 Returns an opaque value that represents the timer.
182 [buffer section]: buffer.html
183 [module system documentation]: modules.html
184 [Modules]: modules.html#modules_modules
185 [process object]: process.html#process_process
186 [console]: console.html
187 [timers]: timers.html