Skip to content

Commit 3bd200a

Browse files
authored
Define process.version and process.versions.node (#520)
1 parent 99f28d7 commit 3bd200a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.changeset/cyan-ears-know.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/cloudflare": patch
3+
---
4+
5+
Define `process.version` and `process.versions.node`

packages/cloudflare/src/cli/templates/worker.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { AsyncLocalStorage } from "node:async_hooks";
2+
import process from "node:process";
23

34
import type { CloudflareContext } from "../../api";
45
// @ts-expect-error: resolved by wrangler build
@@ -67,6 +68,13 @@ function populateProcessEnv(url: URL, env: CloudflareEnv) {
6768
if (processEnvPopulated) {
6869
return;
6970
}
71+
72+
// Some packages rely on `process.version` and `process.versions.node` (i.e. Jose@4)
73+
// TODO: Remove when https://github.com/unjs/unenv/pull/493 is merged
74+
Object.assign(process, { version: process.version || "v22.14.0" });
75+
// @ts-expect-error Node type does not match workerd
76+
Object.assign(process.versions, { node: "22.14.0", ...process.versions });
77+
7078
processEnvPopulated = true;
7179

7280
for (const [key, value] of Object.entries(env)) {

0 commit comments

Comments
 (0)