From 916a92f003900661f25ef513acfaa81b76aec296 Mon Sep 17 00:00:00 2001 From: Vineet Bambah Date: Thu, 21 Aug 2025 16:14:03 +0530 Subject: [PATCH 1/2] Set NODE_OPTIONS environment variable for npm commands --- preswald/build.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/preswald/build.py b/preswald/build.py index 18c50f114..700762bb2 100644 --- a/preswald/build.py +++ b/preswald/build.py @@ -1,11 +1,16 @@ """Build utilities for preswald.""" +import os import shutil import subprocess import sys from pathlib import Path +env = os.environ.copy() +env["NODE_OPTIONS"] = env.get("NODE_OPTIONS", "--max-old-space-size=4096") + + def _run_npm_command(cmd: str, cwd: Path) -> int: """Run an npm command in the specified directory.""" npm_path = shutil.which("npm") From 727abea47510a2337432f790cb2823a8019d1e61 Mon Sep 17 00:00:00 2001 From: Vineet Bambah Date: Thu, 21 Aug 2025 16:33:59 +0530 Subject: [PATCH 2/2] pass the updated environment to the _run_npm_command function --- preswald/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preswald/build.py b/preswald/build.py index 700762bb2..e411ac5b9 100644 --- a/preswald/build.py +++ b/preswald/build.py @@ -18,7 +18,7 @@ def _run_npm_command(cmd: str, cwd: Path) -> int: print("Error: npm not found. Please install npm first.", file=sys.stderr) return 1 - result = subprocess.run([npm_path, *cmd.split()], cwd=cwd, check=False) + result = subprocess.run([npm_path, *cmd.split()], cwd=cwd, check=False, env=env) return result.returncode