Process

sealed external interface Process : EventEmitter(source)

Properties

Link copied to clipboard

The process.allowedNodeEnvironmentFlags property is a special, read-only Set of flags allowable within the NODE_OPTIONS environment variable.

Link copied to clipboard
abstract val arch: Architecture

The operating system CPU architecture for which the Node.js binary was compiled. Possible values are: 'arm', 'arm64', 'ia32', 'loong64', 'mips', 'mipsel', 'ppc', 'ppc64', 'riscv64', 's390', 's390x', and 'x64'.

Link copied to clipboard
abstract var argv: ReadonlyArray<String>

The process.argv property returns an array containing the command-line arguments passed when the Node.js process was launched. The first element will be {@link execPath}. See process.argv0 if access to the original value of argv[0] is needed. The second element will be the path to the JavaScript file being executed. The remaining elements will be any additional command-line arguments.

Link copied to clipboard
abstract var argv0: String

The process.argv0 property stores a read-only copy of the original value ofargv[0] passed when Node.js starts.

Link copied to clipboard
Link copied to clipboard
abstract var channel: ProcessChannel?

If the Node.js process was spawned with an IPC channel, the process.channel property is a reference to the IPC channel. If no IPC channel exists, this property is undefined.

Link copied to clipboard
abstract val config: ProcessConfig

The process.config property returns a frozen Object containing the JavaScript representation of the configure options used to compile the current Node.js executable. This is the same as the config.gypi file that was produced when running the ./configure script.

Link copied to clipboard
abstract var connected: Boolean

If the Node.js process is spawned with an IPC channel (see the Child Process and Cluster documentation), the process.connected property will return true so long as the IPC channel is connected and will return false after process.disconnect() is called.

Link copied to clipboard
abstract var debugPort: Double

The port used by the Node.js debugger when enabled.

Link copied to clipboard
Link copied to clipboard
abstract var env: ProcessEnv

The process.env property returns an object containing the user environment. See environ(7).

Link copied to clipboard

The process.execArgv property returns the set of Node.js-specific command-line options passed when the Node.js process was launched. These options do not appear in the array returned by the {@link argv} property, and do not include the Node.js executable, the name of the script, or any options following the script name. These options are useful in order to spawn child processes with the same execution environment as the parent.

Link copied to clipboard
abstract var execPath: String

The process.execPath property returns the absolute pathname of the executable that started the Node.js process. Symbolic links, if any, are resolved.

Link copied to clipboard
abstract var exitCode: Any?

A number which will be the process exit code, when the process either exits gracefully, or is exited via {@link exit} without specifying a code.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract var getegid: () -> Double?

The process.getegid() method returns the numerical effective group identity of the Node.js process. (See getegid(2).)

Link copied to clipboard
abstract var geteuid: () -> Double?

The process.geteuid() method returns the numerical effective user identity of the process. (See geteuid(2).)

Link copied to clipboard
abstract var getgid: () -> Double?

The process.getgid() method returns the numerical group identity of the process. (See getgid(2).)

Link copied to clipboard
abstract var getgroups: () -> ReadonlyArray<Double>?

The process.getgroups() method returns an array with the supplementary group IDs. POSIX leaves it unspecified if the effective group ID is included but Node.js ensures it always is.

Link copied to clipboard
abstract var getuid: () -> Double?

The process.getuid() method returns the numeric user identity of the process. (See getuid(2).)

Link copied to clipboard
abstract var hrtime: HRTime
Link copied to clipboard
abstract var mainModule: Module?

The process.mainModule property provides an alternative way of retrieving require.main. The difference is that if the main module changes at runtime, require.main may still refer to the original main module in modules that were required before the change occurred. Generally, it's safe to assume that the two refer to the same module.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

This API is available through the --experimental-permission flag.

Link copied to clipboard
abstract val pid: Double

The process.pid property returns the PID of the process.

Link copied to clipboard
abstract val platform: Platform

The process.platform property returns a string identifying the operating system platform for which the Node.js binary was compiled.

Link copied to clipboard
abstract val ppid: Double

The process.ppid property returns the PID of the parent of the current process.

Link copied to clipboard
Link copied to clipboard
abstract val release: ProcessRelease

The process.release property returns an Object containing metadata related to the current release, including URLs for the source tarball and headers-only tarball.

Link copied to clipboard
abstract var report: ProcessReport

process.report is an object whose methods are used to generate diagnostic reports for the current process. Additional documentation is available in the report documentation.

Link copied to clipboard
abstract val send: (message: Any?, sendHandle: Any?, options: ProcessSendOptions?, callback: (JsError?) -> Unit?) -> Boolean?

If Node.js is spawned with an IPC channel, the process.send() method can be used to send messages to the parent process. Messages will be received as a 'message' event on the parent's ChildProcess object.

Link copied to clipboard
abstract var setegid: (id: Any) -> Unit?

The process.setegid() method sets the effective group identity of the process. (See setegid(2).) The id can be passed as either a numeric ID or a group name string. If a group name is specified, this method blocks while resolving the associated a numeric ID.

Link copied to clipboard
abstract var seteuid: (id: Any) -> Unit?

The process.seteuid() method sets the effective user identity of the process. (See seteuid(2).) The id can be passed as either a numeric ID or a username string. If a username is specified, the method blocks while resolving the associated numeric ID.

Link copied to clipboard
abstract var setgid: (id: Any) -> Unit?

The process.setgid() method sets the group identity of the process. (See setgid(2).) The id can be passed as either a numeric ID or a group name string. If a group name is specified, this method blocks while resolving the associated numeric ID.

Link copied to clipboard
abstract var setgroups: (ReadonlyArray<Any>) -> Unit?

The process.setgroups() method sets the supplementary group IDs for the Node.js process. This is a privileged operation that requires the Node.js process to have root or the CAP_SETGID capability.

Link copied to clipboard
abstract var setuid: (id: Any) -> Unit?

The process.setuid(id) method sets the user identity of the process. (See setuid(2).) The id can be passed as either a numeric ID or a username string. If a username is specified, the method blocks while resolving the associated numeric ID.

Link copied to clipboard

The process.sourceMapsEnabled property returns whether the Source Map v3 support for stack traces is enabled.

Link copied to clipboard
abstract var stderr: ProcessStderr

The process.stderr property returns a stream connected tostderr (fd 2). It is a net.Socket (which is a Duplex stream) unless fd 2 refers to a file, in which case it is a Writable stream.

Link copied to clipboard
abstract var stdin: ProcessStdin

The process.stdin property returns a stream connected tostdin (fd 0). It is a net.Socket (which is a Duplex stream) unless fd 0 refers to a file, in which case it is a Readable stream.

Link copied to clipboard
abstract var stdout: ProcessStdout

The process.stdout property returns a stream connected tostdout (fd 1). It is a net.Socket (which is a Duplex stream) unless fd 1 refers to a file, in which case it is a Writable stream.

Link copied to clipboard

The initial value of process.throwDeprecation indicates whether the --throw-deprecation flag is set on the current Node.js process. process.throwDeprecation is mutable, so whether or not deprecation warnings result in errors may be altered at runtime. See the documentation for the 'warning' event and the emitWarning() method for more information.

Link copied to clipboard
abstract var title: String

The process.title property returns the current process title (i.e. returns the current value of ps). Assigning a new value to process.title modifies the current value of ps.

Link copied to clipboard

The process.traceDeprecation property indicates whether the --trace-deprecation flag is set on the current Node.js process. See the documentation for the 'warning' event and the emitWarning() method for more information about this flag's behavior.

Link copied to clipboard
abstract val version: String

The process.version property contains the Node.js version string.

Link copied to clipboard

The process.versions property returns an object listing the version strings of Node.js and its dependencies. process.versions.modules indicates the current ABI version, which is increased whenever a C++ API changes. Node.js will refuse to load modules that were compiled against a different module ABI version.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
abstract fun abort(): Nothing

The process.abort() method causes the Node.js process to exit immediately and generate a core file.

Link copied to clipboard
fun addListener(type: EventType, listener: EventListener)

Alias for emitter.on(eventName, listener).

abstract fun addListener(event: Signals, listener: SignalsListener)
Link copied to clipboard
abstract fun availableMemory(): Double

Gets the amount of free memory that is still available to the process (in bytes). See uv_get_available_memory for more information.

Link copied to clipboard
abstract fun chdir(directory: String)

The process.chdir() method changes the current working directory of the Node.js process or throws an exception if doing so fails (for instance, if the specified directory does not exist).

Link copied to clipboard
abstract fun constrainedMemory(): Double

Gets the amount of memory available to the process (in bytes) based on limits imposed by the OS. If there is no such constraint, or the constraint is unknown, 0 is returned.

Link copied to clipboard
abstract fun cpuUsage(previousValue: CpuUsage = definedExternally): CpuUsage

The process.cpuUsage() method returns the user and system CPU time usage of the current process, in an object with properties user and system, whose values are microsecond values (millionth of a second). These values measure time spent in user and system code respectively, and may end up being greater than actual elapsed time if multiple CPU cores are performing work for this process.

Link copied to clipboard
abstract fun cwd(): String

The process.cwd() method returns the current working directory of the Node.js process.

Link copied to clipboard
abstract fun disconnect()

If the Node.js process is spawned with an IPC channel (see the Child Process and Cluster documentation), the process.disconnect() method will close the IPC channel to the parent process, allowing the child process to exit gracefully once there are no other connections keeping it alive.

Link copied to clipboard
abstract fun dlopen(module: Any, filename: String, flags: Number = definedExternally)

The process.dlopen() method allows dynamically loading shared objects. It is primarily used by require() to load C++ Addons, and should not be used directly, except in special cases. In other words, require() should be preferred over process.dlopen() unless there are specific reasons such as custom dlopen flags or loading from ES modules.

Link copied to clipboard
fun emit(type: EventType, vararg args: Any?): Boolean

Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.

abstract fun emit(event: Signals, signal: Signals = definedExternally): Boolean
Link copied to clipboard
abstract fun emitWarning(warning: String, ctor: Function<*> = definedExternally)
abstract fun emitWarning(warning: JsError, ctor: Function<*> = definedExternally)

The process.emitWarning() method can be used to emit custom or application specific process warnings. These can be listened for by adding a handler to the 'warning' event.

abstract fun emitWarning(warning: String, options: EmitWarningOptions = definedExternally)
abstract fun emitWarning(warning: JsError, options: EmitWarningOptions = definedExternally)
abstract fun emitWarning(warning: String, type: String = definedExternally, ctor: Function<*> = definedExternally)
abstract fun emitWarning(warning: JsError, type: String = definedExternally, ctor: Function<*> = definedExternally)
abstract fun emitWarning(warning: String, type: String = definedExternally, code: String = definedExternally, ctor: Function<*> = definedExternally)
abstract fun emitWarning(warning: JsError, type: String = definedExternally, code: String = definedExternally, ctor: Function<*> = definedExternally)
Link copied to clipboard

Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or Symbols.

Link copied to clipboard
abstract fun exit(): Nothing
abstract fun exit(code: Int? = definedExternally): Nothing
abstract fun exit(code: String? = definedExternally): Nothing

The process.exit() method instructs Node.js to terminate the process synchronously with an exit status of code. If code is omitted, exit uses either the 'success' code 0 or the value of process.exitCode if it has been set. Node.js will not terminate until all the 'exit' event listeners are called.

Link copied to clipboard

The process.getActiveResourcesInfo() method returns an array of strings containing the types of the active resources that are currently keeping the event loop alive.

Link copied to clipboard
abstract fun getBuiltinModule(id: String): Any?

Provides a way to load built-in modules in a globally available function.

Link copied to clipboard

Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to {@link defaultMaxListeners}.

Link copied to clipboard

Indicates whether a callback has been set using {@link setUncaughtExceptionCaptureCallback}.

Link copied to clipboard
abstract fun kill(pid: Number): Boolean
abstract fun kill(pid: Number, signal: Double = definedExternally): Boolean
abstract fun kill(pid: Number, signal: String = definedExternally): Boolean

The process.kill() method sends the signal to the process identified bypid.

Link copied to clipboard
fun listenerCount(type: EventType, listener: EventListener = definedExternally): Double

Returns the number of listeners listening for the event named eventName. If listener is provided, it will return how many times the listener is found in the list of the listeners of the event.

Link copied to clipboard

Returns a copy of the array of listeners for the event named eventName.

Link copied to clipboard
abstract fun loadEnvFile()
abstract fun loadEnvFile(path: String = definedExternally)
abstract fun loadEnvFile(path: Buffer = definedExternally)
abstract fun loadEnvFile(path: URL = definedExternally)

Loads the environment configuration from a .env file into process.env. If the file is not found, error will be thrown.

Link copied to clipboard
abstract fun nextTick(callback: Function<*>, vararg args: Any?)

process.nextTick() adds callback to the "next tick queue". This queue is fully drained after the current operation on the JavaScript stack runs to completion and before the event loop is allowed to continue. It's possible to create an infinite loop if one were to recursively call process.nextTick(). See the Event Loop guide for more background.

Link copied to clipboard
fun off(type: EventType, listener: EventListener)

Alias for emitter.removeListener().

Link copied to clipboard
fun on(type: EventType, listener: EventListener)

Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

abstract fun on(event: Symbol, listener: Function<Unit>)
abstract fun on(event: String, listener: Function<Unit>)
abstract fun on(event: Signals, listener: SignalsListener)
Link copied to clipboard
fun once(type: EventType, listener: EventListener)

Adds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

abstract fun once(event: Symbol, listener: Function<Unit>)
abstract fun once(event: String, listener: Function<Unit>)
abstract fun once(event: Signals, listener: SignalsListener)
Link copied to clipboard

Adds the listener function to the beginning of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

abstract fun prependListener(event: Signals, listener: SignalsListener)
Link copied to clipboard

Adds a one-timelistener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this listener is removed, and then invoked.

abstract fun prependOnceListener(event: Signals, listener: SignalsListener)
Link copied to clipboard

Returns a copy of the array of listeners for the event named eventName, including any wrappers (such as those created by .once()).

Link copied to clipboard
fun removeAllListeners(type: EventType = definedExternally)

Removes all listeners, or those of the specified eventName.

Link copied to clipboard
fun removeListener(type: EventType, listener: EventListener)

Removes the specified listener from the listener array for the event named eventName.

Link copied to clipboard
Link copied to clipboard

By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. The emitter.setMaxListeners() method allows the limit to be modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

Link copied to clipboard
abstract fun setSourceMapsEnabled(value: Boolean)

This function enables or disables the Source Map v3 support for stack traces.

Link copied to clipboard

The process.setUncaughtExceptionCaptureCallback() function sets a function that will be invoked when an uncaught exception occurs, which will receive the exception value itself as its first argument.

Link copied to clipboard
abstract fun umask(): Double

process.umask() returns the Node.js process's file mode creation mask. Child processes inherit the mask from the parent process.

abstract fun umask(mask: Double): Double
abstract fun umask(mask: String): Double

Can only be set if not in worker thread.

Link copied to clipboard
abstract fun uptime(): Double

The process.uptime() method returns the number of seconds the current Node.js process has been running.