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.
58 [buffer section]: buffer.html
59 [module system documentation]: modules.html
60 [Modules]: modules.html#modules_modules
61 [process object]: process.html#process_process
62 [console]: console.html
67 Stop a timer that was previously created with `setTimeout()`. The callback will
76 Used to print to stdout and stderr. See the [console][] section.
82 A reference to the `module.exports` that is shorter to type.
83 See [module system documentation][] for details on when to use `exports` and
84 when to use `module.exports`.
86 `exports` isn't actually a global but rather local to each module.
88 See the [module system documentation][] for more information.
94 * {Object} The global namespace object.
96 In browsers, the top-level scope is the global scope. That means that in
97 browsers if you're in the global scope `var something` will define a global
98 variable. In Node.js this is different. The top-level scope is not the global
99 scope; `var something` inside an Node.js module will be local to that module.
107 A reference to the current module. In particular
108 `module.exports` is used for defining what a module exports and makes
109 available through `require()`.
111 `module` isn't actually a global but rather local to each module.
113 See the [module system documentation][] for more information.
121 The process object. See the [process object][] section.
129 To require modules. See the [Modules][] section. `require` isn't actually a
130 global but rather local to each module.
136 Modules are cached in this object when they are required. By deleting a key
137 value from this object, the next `require` will reload the module.
139 ### require.extensions
141 Stability: 0 - Deprecated
145 Instruct `require` on how to handle certain file extensions.
147 Process files with the extension `.sjs` as `.js`:
149 require.extensions['.sjs'] = require.extensions['.js'];
151 **Deprecated** In the past, this list has been used to load
152 non-JavaScript modules into Node.js by compiling them on-demand.
153 However, in practice, there are much better ways to do this, such as
154 loading modules via some other Node.js program, or compiling them to
155 JavaScript ahead of time.
157 Since the Module system is locked, this feature will probably never go
158 away. However, it may have subtle bugs and complexities that are best
161 ### require.resolve()
163 Use the internal `require()` machinery to look up the location of a module,
164 but rather than loading the module, just return the resolved filename.
166 ## setInterval(cb, ms)
168 Run callback `cb` repeatedly every `ms` milliseconds. Note that the actual
169 interval may vary, depending on external factors like OS timer granularity and
170 system load. It's never less than `ms` but it may be longer.
172 The interval must be in the range of 1-2,147,483,647 inclusive. If the value is
173 outside that range, it's changed to 1 millisecond. Broadly speaking, a timer
174 cannot span more than 24.8 days.
176 Returns an opaque value that represents the timer.
178 ## setTimeout(cb, ms)
180 Run callback `cb` after *at least* `ms` milliseconds. The actual delay depends
181 on external factors like OS timer granularity and system load.
183 The timeout must be in the range of 1-2,147,483,647 inclusive. If the value is
184 outside that range, it's changed to 1 millisecond. Broadly speaking, a timer
185 cannot span more than 24.8 days.
187 Returns an opaque value that represents the timer.