node version logic
This commit is contained in:
@@ -381,17 +381,14 @@ def install_nodejs_from_distro():
|
||||
|
||||
if shutil.which("node"):
|
||||
node_ver = run_out(["node", "--version"], check=False).strip()
|
||||
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...")
|
||||
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"✔ 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)
|
||||
|
||||
Reference in New Issue
Block a user