From 47439874aca8ba1c18b97c7f3ee8456dfbbffad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Sun, 26 Oct 2025 18:54:52 +0100 Subject: [PATCH] node version logic --- npm_install.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/npm_install.py b/npm_install.py index 7baf2ba..7ea0f17 100644 --- a/npm_install.py +++ b/npm_install.py @@ -381,17 +381,14 @@ def install_nodejs_from_distro(): if shutil.which("node"): node_ver = run_out(["node", "--version"], check=False).strip() + print(f"Node.js: {node_ver}") + + if not shutil.which("npm"): + apt_try_install(["npm"]) + if shutil.which("npm"): npm_ver = run_out(["npm", "--version"], check=False).strip() - print(f" Node.js: {node_ver} (from distro)") - print(f" npm: {npm_ver}") - else: - print(f" Node.js: {node_ver} (from distro)") - print(f"⚠ npm not found, installing...") - apt_try_install(["npm"]) - if shutil.which("npm"): - npm_ver = run_out(["npm", "--version"], check=False).strip() - print(f"✔ npm {npm_ver} installed successfully") + print(f"npm: {npm_ver}") return True return False @@ -463,6 +460,7 @@ def ensure_minimum_nodejs(min_version=MIN_NODEJS_VERSION, user_requested_version if has_nodejs and major and major >= min_version: print(f"✓ Distribution provides Node.js v{version_str} (>= v{min_version})") + print() if install_nodejs_from_distro(): return True else: @@ -1393,10 +1391,12 @@ def install_node_from_nodesource(version: str): print(f" Node.js: {node_ver}") print(f" npm: {npm_ver}") else: - print(f" Node.js: {node_ver}") - print(f"⚠ npm not found, installing...") + print(f"Node.js: {node_ver}") + apt_try_install(["npm"]) - run(["apt-get", "install", "-y", "npm"], check=False) + if shutil.which("npm"): + npm_ver = run_out(["npm", "--version"], check=False).strip() + print(f"npm: {npm_ver}") if not shutil.which("npm"): run(["corepack", "enable"], check=False)