fix install on older systems
This commit is contained in:
@@ -13,7 +13,7 @@ Base URL: **https://gitea.linuxiarz.pl/gru/npm-angie-auto-install**
|
|||||||
---
|
---
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
- Debian 12+ / Ubuntu 24.04 (root privileges).
|
- Debian 12+ / Ubuntu 20.04+
|
||||||
- `curl`, `python3`, `sudo`
|
- `curl`, `python3`, `sudo`
|
||||||
- Network access to fetch packages and Node/Yarn artifacts.
|
- Network access to fetch packages and Node/Yarn artifacts.
|
||||||
- ~2 GB RAM (recommended) or add 2 GB swap for safer frontend builds.
|
- ~2 GB RAM (recommended) or add 2 GB swap for safer frontend builds.
|
||||||
|
|||||||
@@ -258,20 +258,31 @@ def set_file_ownership(files: list[str | Path], owner: str, mode: int | None = N
|
|||||||
return len(failed) == 0
|
return len(failed) == 0
|
||||||
|
|
||||||
def ensure_minimum_nodejs(min_version=MIN_NODEJS_VERSION):
|
def ensure_minimum_nodejs(min_version=MIN_NODEJS_VERSION):
|
||||||
try:
|
with step("Checking Node.js version requirements"):
|
||||||
node_ver = runout(["node", "--version"], check=False).strip()
|
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)
|
install_node_from_nodesource(str(min_version))
|
||||||
if match:
|
|
||||||
current_major = int(match.group(1))
|
if shutil.which("node"):
|
||||||
if current_major >= min_version:
|
node_ver = runout(["node", "--version"], check=False).strip()
|
||||||
return True
|
if shutil.which("npm"):
|
||||||
except FileNotFoundError:
|
npm_ver = runout(["npm", "--version"], check=False).strip()
|
||||||
pass
|
printf(f"Node.js: {node_ver}")
|
||||||
except Exception:
|
printf(f" npm: {npm_ver}")
|
||||||
pass
|
else:
|
||||||
|
printf(f"Node.js: {node_ver}")
|
||||||
|
|
||||||
install_node_from_nodesource(str(min_version))
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def download_extract_tar_gz(url: str, dest_dir: Path) -> Path:
|
def download_extract_tar_gz(url: str, dest_dir: Path) -> Path:
|
||||||
@@ -1646,10 +1657,7 @@ def main():
|
|||||||
|
|
||||||
setup_angie(ipv6_enabled=args.enable_ipv6)
|
setup_angie(ipv6_enabled=args.enable_ipv6)
|
||||||
write_metrics_files()
|
write_metrics_files()
|
||||||
|
ensure_minimum_nodejs()
|
||||||
with step("Checking Node.js version requirements"):
|
|
||||||
ensure_minimum_nodejs()
|
|
||||||
|
|
||||||
install_node_and_yarn(node_pkg=args.nodejs_pkg, node_version=args.node_version)
|
install_node_and_yarn(node_pkg=args.nodejs_pkg, node_version=args.node_version)
|
||||||
ensure_user_and_dirs()
|
ensure_user_and_dirs()
|
||||||
create_sudoers_for_npm()
|
create_sudoers_for_npm()
|
||||||
|
|||||||
Reference in New Issue
Block a user