Node.js v11.15.0 Documentation


Table of Contents

Deprecated APIs#

Node.js may deprecate APIs when either: (a) use of the API is considered to be unsafe, (b) an improved alternative API is available, or (c) breaking changes to the API are expected in a future major release.

Node.js utilizes three kinds of Deprecations:

  • Documentation-only
  • Runtime
  • End-of-Life

A Documentation-only deprecation is one that is expressed only within the Node.js API docs. These generate no side-effects while running Node.js. Some Documentation-only deprecations trigger a runtime warning when launched with --pending-deprecation flag (or its alternative, NODE_PENDING_DEPRECATION=1 environment variable), similarly to Runtime deprecations below. Documentation-only deprecations that support that flag are explicitly labeled as such in the list of Deprecated APIs.

A Runtime deprecation will, by default, generate a process warning that will be printed to stderr the first time the deprecated API is used. When the --throw-deprecation command-line flag is used, a Runtime deprecation will cause an error to be thrown.

An End-of-Life deprecation is used when functionality is or will soon be removed from Node.js.

Revoking deprecations#

Occasionally, the deprecation of an API may be reversed. In such situations, this document will be updated with information relevant to the decision. However, the deprecation identifier will not be modified.

List of Deprecated APIs#

DEP0001: http.OutgoingMessage.prototype.flush#

Type: Runtime

The OutgoingMessage.prototype.flush() method is deprecated. Use OutgoingMessage.prototype.flushHeaders() instead.

DEP0002: require('_linklist')#

Type: End-of-Life

The _linklist module is deprecated. Please use a userland alternative.

DEP0003: _writableState.buffer#

Type: Runtime

The _writableState.buffer property is deprecated. Use the _writableState.getBuffer() method instead.

DEP0004: CryptoStream.prototype.readyState#

Type: End-of-Life

The CryptoStream.prototype.readyState property was removed.

DEP0005: Buffer() constructor#

Type: Runtime (supports --pending-deprecation)

The Buffer() function and new Buffer() constructor are deprecated due to API usability issues that can potentially lead to accidental security issues.

As an alternative, use of the following methods of constructing Buffer objects is strongly recommended:

As of v10.0.0, a deprecation warning is printed at runtime when --pending-deprecation is used or when the calling code is outside node_modules in order to better target developers, rather than users.

DEP0006: child_process options.customFds#

Type: Runtime

Within the child_process module's spawn(), fork(), and exec() methods, the options.customFds option is deprecated. The options.stdio option should be used instead.

DEP0007: Replace cluster worker.suicide with worker.exitedAfterDisconnect#

Type: End-of-Life

In an earlier version of the Node.js cluster, a boolean property with the name suicide was added to the Worker object. The intent of this property was to provide an indication of how and why the Worker instance exited. In Node.js 6.0.0, the old property was deprecated and replaced with a new worker.exitedAfterDisconnect property. The old property name did not precisely describe the actual semantics and was unnecessarily emotion-laden.

DEP0008: require('constants')#

Type: Documentation-only

The constants module is deprecated. When requiring access to constants relevant to specific Node.js builtin modules, developers should instead refer to the constants property exposed by the relevant module. For instance, require('fs').constants and require('os').constants.

DEP0009: crypto.pbkdf2 without digest#

Type: Runtime

Use of the crypto.pbkdf2() API without specifying a digest was deprecated in Node.js 6.0 because the method defaulted to using the non-recommended 'SHA1' digest. Previously, a deprecation warning was printed. Starting in Node.js 8.0.0, calling crypto.pbkdf2() or crypto.pbkdf2Sync() with digest set to undefined will throw a TypeError.

Beginning in Node.js v11.0.0, calling these functions with digest set to null will print a deprecation warning to align with the behavior when digest is undefined.

DEP0010: crypto.createCredentials#

Type: End-of-Life

The crypto.createCredentials() API was removed. Please use tls.createSecureContext() instead.

DEP0011: crypto.Credentials#

Type: End-of-Life

The crypto.Credentials class was removed. Please use tls.SecureContext instead.

DEP0012: Domain.dispose#

Type: End-of-Life

Domain.dispose() has been removed. Recover from failed I/O actions explicitly via error event handlers set on the domain instead.

DEP0013: fs asynchronous function without callback#

Type: End-of-Life

Calling an asynchronous function without a callback throws a TypeError in Node.js 10.0.0 onwards. (See https://github.com/nodejs/node/pull/12562.)

DEP0014: fs.read legacy String interface#

Type: End-of-Life

The fs.read() legacy String interface is deprecated. Use the Buffer API as mentioned in the documentation instead.

DEP0015: fs.readSync legacy String interface#

Type: End-of-Life

The fs.readSync() legacy String interface is deprecated. Use the Buffer API as mentioned in the documentation instead.

DEP0016: GLOBAL/root#

Type: Runtime

The GLOBAL and root aliases for the global property are deprecated and should no longer be used.

DEP0017: Intl.v8BreakIterator#

Type: End-of-Life

Intl.v8BreakIterator was a non-standard extension and has been removed. See Intl.Segmenter.

DEP0018: Unhandled promise rejections#

Type: Runtime

Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

DEP0019: require('.') resolved outside directory#

Type: Runtime

In certain cases, require('.') may resolve outside the package directory. This behavior is deprecated and will be removed in a future major Node.js release.

DEP0020: Server.connections#

Type: Runtime

The Server.connections property is deprecated. Please use the Server.getConnections() method instead.

DEP0021: Server.listenFD#

Type: Runtime

The Server.listenFD() method is deprecated. Please use Server.listen({fd: <number>}) instead.

DEP0022: os.tmpDir()#

Type: Runtime

The os.tmpDir() API is deprecated. Please use os.tmpdir() instead.

DEP0023: os.getNetworkInterfaces()#

Type: Runtime

The os.getNetworkInterfaces() method is deprecated. Please use the os.networkInterfaces property instead.

DEP0024: REPLServer.prototype.convertToContext()#

Type: End-of-Life

The REPLServer.prototype.convertToContext() API has been removed.

DEP0025: require('sys')#

Type: Runtime

The sys module is deprecated. Please use the util module instead.

DEP0026: util.print()#

Type: Runtime

The util.print() API is deprecated. Please use console.log() instead.

DEP0027: util.puts()#

Type: Runtime

The util.puts() API is deprecated. Please use console.log() instead.

DEP0028: util.debug()#

Type: Runtime

The util.debug() API is deprecated. Please use console.error() instead.

DEP0029: util.error()#

Type: Runtime

The util.error() API is deprecated. Please use console.error() instead.

DEP0030: SlowBuffer#

Type: Documentation-only

The SlowBuffer class is deprecated. Please use Buffer.allocUnsafeSlow(size) instead.

DEP0031: ecdh.setPublicKey()#

Type: Documentation-only

The ecdh.setPublicKey() method is now deprecated as its inclusion in the API is not useful.

DEP0032: domain module#

Type: Documentation-only

The domain module is deprecated and should not be used.

DEP0033: EventEmitter.listenerCount()#

Type: Documentation-only

The EventEmitter.listenerCount(emitter, eventName) API is deprecated. Please use emitter.listenerCount(eventName) instead.

DEP0034: fs.exists(path, callback)[src]#

Type: Documentation-only

The fs.exists(path, callback) API is deprecated. Please use fs.stat() or fs.access() instead.

DEP0035: fs.lchmod(path, mode, callback)#

Type: Documentation-only

The fs.lchmod(path, mode, callback) API is deprecated.

DEP0036: fs.lchmodSync(path, mode)#

Type: Documentation-only

The fs.lchmodSync(path, mode) API is deprecated.

DEP0037: fs.lchown(path, uid, gid, callback)[src]#

Type: Deprecation revoked

The fs.lchown(path, uid, gid, callback) API is deprecated.

DEP0038: fs.lchownSync(path, uid, gid)[src]#

Type: Deprecation revoked

The fs.lchownSync(path, uid, gid) API is deprecated.

DEP0039: require.extensions#

Type: Documentation-only

The require.extensions property is deprecated.

DEP0040: punycode module#

Type: Documentation-only

The punycode module is deprecated. Please use a userland alternative instead.

DEP0041: NODE_REPL_HISTORY_FILE environment variable#

Type: End-of-Life

The NODE_REPL_HISTORY_FILE environment variable was removed. Please use NODE_REPL_HISTORY instead.

DEP0042: tls.CryptoStream#

Type: End-of-Life

The tls.CryptoStream class was removed. Please use tls.TLSSocket instead.

DEP0043: tls.SecurePair#

Type: Documentation-only

The tls.SecurePair class is deprecated. Please use tls.TLSSocket instead.

DEP0044: util.isArray()#

Type: Documentation-only

The util.isArray() API is deprecated. Please use Array.isArray() instead.

DEP0045: util.isBoolean()[src]#

Type: Documentation-only

The util.isBoolean() API is deprecated.

DEP0046: util.isBuffer()#

Type: Documentation-only

The util.isBuffer() API is deprecated. Please use Buffer.isBuffer() instead.

DEP0047: util.isDate()#

Type: Documentation-only

The