Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

fix: add node version check (#1007)

Fouad Matina86270f58135
diff --git a/codex-cli/src/cli.tsx b/codex-cli/src/cli.tsx
index dfa2b3bb8c..c7e5d9ff31 100644
--- a/codex-cli/src/cli.tsx
+++ b/codex-cli/src/cli.tsx
@@ -1,6 +1,19 @@
#!/usr/bin/env node
import "dotenv/config";
+// Exit early if on an older version of Node.js (< 22)
+const major = process.versions.node.split(".").map(Number)[0]!;
+if (major < 22) {
+ // eslint-disable-next-line no-console
+ console.error(
+ "\n" +
+ "Codex CLI requires Node.js version 22 or newer.\n" +
+ `You are running Node.js v${process.versions.node}.\n` +
+ "Please upgrade Node.js: https://nodejs.org/en/download/\n",
+ );
+ process.exit(1);
+}
+
// Hack to suppress deprecation warnings (punycode)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(process as any).noDeprecation = true;