Skip to content

Commit a0e222c

Browse files
authored
FIX: Windows support for npm lookup (#1569)
1 parent bd23ce5 commit a0e222c

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

build_scripts/prepare_package.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ def build_frontend(frontend_dir: Path) -> bool:
2626
print("Building TypeScript/React frontend...")
2727
print("=" * 60)
2828

29-
# Check if npm is available
29+
# Check if npm is available (with cross-platform compatibility)
30+
npm = shutil.which("npm")
3031
try:
31-
result = subprocess.run(["npm", "--version"], capture_output=True, text=True, check=True)
32+
if npm is None:
33+
raise FileNotFoundError("npm not found")
34+
result = subprocess.run([npm, "--version"], capture_output=True, text=True, check=True)
3235
print(f"Found npm version: {result.stdout.strip()}")
3336
except (subprocess.CalledProcessError, FileNotFoundError):
3437
print("ERROR: npm is not installed or not in PATH")
@@ -45,7 +48,7 @@ def build_frontend(frontend_dir: Path) -> bool:
4548
print("\nInstalling frontend dependencies...")
4649
try:
4750
subprocess.run(
48-
["npm", "install"],
51+
[npm, "install"],
4952
cwd=frontend_dir,
5053
check=True,
5154
stdout=subprocess.PIPE,
@@ -61,7 +64,7 @@ def build_frontend(frontend_dir: Path) -> bool:
6164
print("\nBuilding frontend for production...")
6265
try:
6366
subprocess.run(
64-
["npm", "run", "build"],
67+
[npm, "run", "build"],
6568
cwd=frontend_dir,
6669
check=True,
6770
stdout=subprocess.PIPE,

0 commit comments

Comments
 (0)