- About these Docs
- Synopsis
- Assertion Testing
- Buffer
- C/C++ Addons
- Child Processes
- Cluster
- Command Line Options
- Console
- Crypto
- Debugger
- DNS
- Domain
- Errors
- Events
- File System
- Globals
- HTTP
- HTTPS
- Modules
- Net
- OS
- Path
- Process
- Punycode
- Query Strings
- Readline
- REPL
- Stream
- String Decoder
- Timers
- TLS/SSL
- TTY
- UDP/Datagram
- URL
- Utilities
- V8
- VM
- ZLIB
Node.js v5.12.0 Documentation
Table of Contents
- Global Objects
Global Objects#
These objects are available in all modules. Some of these objects aren't actually in the global scope but in the module scope - this will be noted.
Class: Buffer#
Used to handle binary data. See the buffer section.
__dirname#
The name of the directory that the currently executing script resides in.
Example: running node example.js from /Users/mjr
console.log(__dirname);
// /Users/mjr
__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
a 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
/Users/mjr/app/node_modules/b while references to __dirname within a.js
will return /Users/mj/app.
__filename#
The filename of the code being executed. This is the resolved absolute path of this code file. For a main program this is not necessarily the same filename used in the command line. The value inside a module is the path to that module file.
Example: running node example.js from /Users/mjr
console.log(__filename);
// /Users/mjr/example.js
__filename isn't actually a global but rather local to each module.
clearImmediate(immediateObject)#
clearImmediate is described in the timers section.
clearInterval(intervalObject)#
clearInterval is described in the timers section.
clearTimeout(timeoutObject)#
clearTimeout is described in the timers section.