You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When enabled after 2025-09-15, the `enable_nodejs_process_v2` flag along with the [`nodejs_compat`](/workers/runtime-apis/nodejs/) compat flag
10
+
ensures a comprehensive Node.js-compatible `process` implementation, updating from the previous minimal process implementation
11
+
that only provided the limited `nextTick`, `env`, `exit`, `getBuiltinModule`, `platform` and `features` properties.
12
+
13
+
To continue using the previous minimal implementation after the compat date, set the `disable_nodejs_process_v2` flag instead.
14
+
15
+
Most Node.js-supported process properties are implemented where possible, with undefined exports for unsupported features. See the [process documentation](/workers/runtime-apis/nodejs/process/) for Workers-specific implementation details.
The [`process`](https://nodejs.org/dist/latest-v19.x/docs/api/process.html) module in Node.js provides a number of useful APIs related to the current process. Within a serverless environment like Workers, most of these APIs are not relevant or meaningful, but some are useful for cross-runtime compatibility. Within Workers, the following APIs are available:
10
+
The [`process`](https://nodejs.org/docs/latest/api/process.html) module in Node.js provides a number of useful APIs related to the current process.
11
11
12
-
```js
13
-
import { env, nextTick } from"node:process";
12
+
Initially Workers only supported `nextTick`, `env`, `exit`, `getBuiltinModule`, `platform` and `features` on process,
13
+
which was then updated with the [`enable_nodejs_process_v2`](/workers/configuration/compatibility-flags/#enable-process-v2-implementation) flag to include most Node.js process features.
14
14
15
-
env["FOO"] ="bar";
16
-
console.log(env["FOO"]); // Prints: bar
15
+
Refer to the [Node.js documentation for `process`](https://nodejs.org/docs/latest/api/process.html) for more information.
17
16
18
-
nextTick(() => {
19
-
console.log("next tick");
20
-
});
21
-
```
17
+
Workers-specific implementation details apply when adapting Node.js process support for a serverless environment, which are described in more detail below.
22
18
23
19
## `process.env`
24
20
@@ -77,5 +73,47 @@ process.env === env; // false! they are no longer the same object
77
73
78
74
The Workers implementation of`process.nextTick()` is a wrapper for the standard Web Platform API [`queueMicrotask()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/queueMicrotask).
79
75
80
-
Refer to the [Node.js documentation for`process`](https://nodejs.org/dist/latest-v19.x/docs/api/process.html) for more information.
76
+
```js
77
+
import { env, nextTick } from "node:process";
78
+
79
+
env["FOO"] = "bar";
80
+
console.log(env["FOO"]); // Prints: bar
81
+
82
+
nextTick(() => {
83
+
console.log("next tick");
84
+
});
85
+
```
86
+
87
+
## Stdio
88
+
89
+
[`process.stdout`](https://nodejs.org/docs/latest/api/process.html#processstdout), [`process.stderr`](https://nodejs.org/docs/latest/api/process.html#processstderr) and [`process.stdin`](https://nodejs.org/docs/latest/api/process.html#processstdin) are supported as streams. `stdin` is treated as an empty readable stream.
90
+
`stdout` and `stderr` are non-TTY writable streams, which output to normal logging output only with`stdout: ` and `stderr: ` prefixing.
91
+
92
+
The line buffer works by storing writes to stdout or stderr until either a newline character `\n` is encountered or until the next microtask, when the log is then flushed to the output.
93
+
94
+
This ensures compatibility with inspector and structured logging outputs.
95
+
96
+
## Current Working Directory
97
+
98
+
[`process.cwd()`](https://nodejs.org/docs/latest/api/process.html#processcwd) is the _current workding directory_, used as the default path for all filesystem operations, and is initialized to `/bundle`.
99
+
100
+
[`process.chdir()`](https://nodejs.org/docs/latest/api/process.html#processchdirdirectory) allows modifying the `cwd` and is respected by FS operations when using `enable_nodejs_fs_module`.
101
+
102
+
## Hrtime
103
+
104
+
While [`process.hrtime`](https://nodejs.org/docs/latest/api/process.html#processhrtimetime) high-resolution timer is available, it provides an inaccurate timer for compatibility only.
105
+
106
+
## Unsupported Features
107
+
108
+
The following `process` properties are currently entirely unsupported and return`undefined`:`binding`, `channel`, `connected`, `debugPort`, `dlopen`,
0 commit comments