11from utils .platform_info import get_platform_and_model_info
22import sys
33import re
4+ import subprocess
5+ import shutil
46import logging
7+
58logger = logging .getLogger (__name__ )
69
710MIN_MEMORY_GB = 32
811REQUIRED_OS = "Windows 11"
912REQUIRED_PYTHON_MAJOR = 3
1013REQUIRED_PYTHON_MINOR = 12
14+ REQUIRED_NODE_MAJOR = 18 # Minimum required Node.js version
15+
1116
1217def check_meteor_lake (processor_name : str ) -> bool :
1318 try :
@@ -18,6 +23,7 @@ def check_meteor_lake(processor_name: str) -> bool:
1823 except Exception :
1924 return False
2025
26+
2127def parse_memory_gb (memory_str : str ) -> float :
2228 try :
2329 if not memory_str :
@@ -27,6 +33,7 @@ def parse_memory_gb(memory_str: str) -> float:
2733 except Exception :
2834 return 0
2935
36+
3037def check_python_version () -> bool :
3138 try :
3239 major = sys .version_info .major
@@ -35,11 +42,47 @@ def check_python_version() -> bool:
3542 except Exception :
3643 return False
3744
45+
46+ def check_nodejs_version () -> bool :
47+ """
48+ Checks if Node.js is installed and meets the minimum version requirement.
49+ Returns True if Node.js exists and version >= REQUIRED_NODE_MAJOR.
50+ """
51+ try :
52+ node_path = shutil .which ("node" )
53+ if node_path is None :
54+ logger .error ("❌ Node.js is not installed or not found in PATH." )
55+ return False
56+
57+ version_output = subprocess .check_output (["node" , "--version" ], text = True ).strip ()
58+ logger .info (f"✅ Node.js found: { version_output } " )
59+
60+ # Parse version (e.g., v18.16.0 → 18)
61+ match = re .match (r"v(\d+)" , version_output )
62+ if not match :
63+ logger .error ("⚠️ Unable to parse Node.js version output." )
64+ return False
65+
66+ major_version = int (match .group (1 ))
67+ if major_version < REQUIRED_NODE_MAJOR :
68+ logger .error (f"⚠️ Node.js version { major_version } is too old. Please install Node.js v{ REQUIRED_NODE_MAJOR } +." )
69+ return False
70+
71+ return True
72+
73+ except Exception as e :
74+ logger .error (f"⚠️ Node.js check failed: { e } " )
75+ return False
76+
77+
3878def check_system_requirements () -> bool :
79+ """
80+ Checks the overall system environment for compatibility.
81+ Returns True only if all major requirements are satisfied.
82+ """
3983 try :
4084 info = get_platform_and_model_info ()
4185 except Exception :
42- # If fetching info itself fails
4386 return False
4487
4588 try :
@@ -49,9 +92,10 @@ def check_system_requirements() -> bool:
4992 return False
5093 if not check_python_version ():
5194 return False
95+ if not check_nodejs_version ():
96+ return False
5297 return True
5398 except Exception :
54- # Any unexpected failure in checks should return False
5599 return False
56100
57101
@@ -83,4 +127,4 @@ def show_warning_and_prompt_user_to_continue():
83127 return False
84128 return True
85129 except KeyboardInterrupt :
86- return False
130+ return False
0 commit comments