feat: add a warning that shows if user uses node -v <20 #2930 (#3371)

Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
Devansh Sharma
2025-07-15 11:49:46 +02:00
committed by GitHub
parent f5d5213504
commit 123c3e7c7f
2 changed files with 63 additions and 1 deletions

View File

@@ -6,6 +6,7 @@
import fs from 'fs/promises';
import * as os from 'os';
import semver from 'semver';
type WarningCheck = {
id: string;
@@ -32,8 +33,23 @@ const homeDirectoryCheck: WarningCheck = {
},
};
const nodeVersionCheck: WarningCheck = {
id: 'node-version',
check: async (_workspaceRoot: string) => {
const minMajor = 20;
const major = semver.major(process.versions.node);
if (major < minMajor) {
return `You are using Node.js v${process.versions.node}. Gemini CLI requires Node.js ${minMajor} or higher for best results.`;
}
return null;
},
};
// All warning checks
const WARNING_CHECKS: readonly WarningCheck[] = [homeDirectoryCheck];
const WARNING_CHECKS: readonly WarningCheck[] = [
homeDirectoryCheck,
nodeVersionCheck,
];
export async function getUserStartupWarnings(
workspaceRoot: string,