diff --git a/README.md b/README.md index 9c2ae55..b4d3f19 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Base URL: **https://gitea.linuxiarz.pl/gru/npm-angie-auto-install** --- ## Requirements -- Debian 12+ / Ubuntu 24.04 (root privileges). +- Debian 12+ / Ubuntu 20.04+ - `curl`, `python3`, `sudo` - Network access to fetch packages and Node/Yarn artifacts. - ~2 GB RAM (recommended) or add 2 GB swap for safer frontend builds. diff --git a/npm_install.py b/npm_install.py index bb2345f..77cb25a 100644 --- a/npm_install.py +++ b/npm_install.py @@ -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()