fix install on older systems

This commit is contained in:
Mateusz Gruszczyński
2025-10-26 15:58:48 +01:00
parent 9826d14a36
commit 82fd1d6606
2 changed files with 25 additions and 17 deletions

View File

@@ -258,20 +258,31 @@ def set_file_ownership(files: list[str | Path], owner: str, mode: int | None = N
return len(failed) == 0
def ensure_minimum_nodejs(min_version=MIN_NODEJS_VERSION):
try:
node_ver = runout(["node", "--version"], check=False).strip()
with step("Checking Node.js version requirements"):
try:
node_ver = runout(["node", "--version"], check=False).strip()
match = re.match(r'v?(\d+)', node_ver)
if match:
current_major = int(match.group(1))
if current_major >= min_version:
return True
except FileNotFoundError:
pass
except Exception:
pass
match = re.match(r'v?(\d+)', node_ver)
if match:
current_major = int(match.group(1))
if current_major >= min_version:
return True
except FileNotFoundError:
pass
except Exception:
pass
install_node_from_nodesource(str(min_version))
if shutil.which("node"):
node_ver = runout(["node", "--version"], check=False).strip()
if shutil.which("npm"):
npm_ver = runout(["npm", "--version"], check=False).strip()
printf(f"Node.js: {node_ver}")
printf(f" npm: {npm_ver}")
else:
printf(f"Node.js: {node_ver}")
install_node_from_nodesource(str(min_version))
return True
def download_extract_tar_gz(url: str, dest_dir: Path) -> Path:
@@ -1646,10 +1657,7 @@ def main():
setup_angie(ipv6_enabled=args.enable_ipv6)
write_metrics_files()
with step("Checking Node.js version requirements"):
ensure_minimum_nodejs()
ensure_minimum_nodejs()
install_node_and_yarn(node_pkg=args.nodejs_pkg, node_version=args.node_version)
ensure_user_and_dirs()
create_sudoers_for_npm()