Skip to content

Commit d29d777

Browse files
authored
nodejs check (#918)
1 parent 5a3279e commit d29d777

File tree

2 files changed

+50
-8
lines changed

2 files changed

+50
-8
lines changed

education-ai-suite/smart-classroom/docs/user-guide/get-started.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ To install dependencies, do the following:
88

99
**a. Install [FFmpeg](https://ffmpeg.org/download.html)** (required for audio processing):
1010

11-
- On **Windows**:
12-
Download from [https://ffmpeg.org/download.html](https://ffmpeg.org/download.html), and add the `ffmpeg/bin` folder to your system `PATH`.
11+
- Download from [https://ffmpeg.org/download.html](https://ffmpeg.org/download.html), and add the `ffmpeg/bin` folder to your system `PATH`.
1312

1413
**Run your shell with admin privileges before starting the application**
1514

@@ -30,9 +29,9 @@ It’s recommended to create a **dedicated Python virtual environment** for the
3029

3130
```bash
3231
python -m venv smartclassroom
33-
# On Windows:
3432
smartclassroom\Scripts\activate
3533

34+
# Make sure you are using Python 3.12.x before running pip.
3635
python.exe -m pip install --upgrade pip
3736
pip install --pre --upgrade ipex-llm[xpu_2.6] --extra-index-url https://download.pytorch.org/whl/xpu
3837
cd smart-classroom
@@ -46,7 +45,6 @@ If you plan to use IPEX, create a separate virtual environment.
4645

4746
```bash
4847
python -m venv smartclassroom_ipex
49-
# On Windows:
5048
smartclassroom_ipex\Scripts\activate
5149

5250
python.exe -m pip install --upgrade pip
@@ -173,4 +171,4 @@ If you changed the port, adjust the URL accordingly.
173171
Either openvino_tokenizer.xml was not provided or it was not loaded correctly. Tokenizer::encode is not available
174172
```
175173

176-
Delete the models folder from `edge-ai-suites/education-ai-suite/smart-classroom/models` and try again.
174+
Delete the models folder from `edge-ai-suites/education-ai-suite/smart-classroom/models` and try again.

education-ai-suite/smart-classroom/utils/system_checker.py

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
from utils.platform_info import get_platform_and_model_info
22
import sys
33
import re
4+
import subprocess
5+
import shutil
46
import logging
7+
58
logger = logging.getLogger(__name__)
69

710
MIN_MEMORY_GB = 32
811
REQUIRED_OS = "Windows 11"
912
REQUIRED_PYTHON_MAJOR = 3
1013
REQUIRED_PYTHON_MINOR = 12
14+
REQUIRED_NODE_MAJOR = 18 # Minimum required Node.js version
15+
1116

1217
def 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+
2127
def 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+
3037
def 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+
3878
def 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

Comments
 (0)