Request: Allow version ranges
It would be great if I could define version ranges instead of exact versions, e.g. 4.x or ^4.3.1. It is probably best to use npm syntax for these ranges.
specifically, it would be awesome if nodeenv could take a version range and only install a full nodeenv if the system-provided one doesn't satisfy the version requirement...
It would be nice for scripting the installation if requirement specifiers were supported (like for pip packages) for specifying nodejs/npm versions:
nodeenv --node ">=20.0.0"
nodeenv --node "~=22.0.0"
nodeenv --node "<21.0.0"
Furthermore, it would also be nice to be able to just specify the major (and optionally minor) version (to install the latest one that matches):
nodeenv --node 22
nodeenv --node 21.7
You can easily hack something together to script this, e.g.
import re
import subprocess
from packaging.version import parse
from shlex import split
def set_up_node(nodejs_version: str = "22"):
subprocess.run(split("nodeenv --list"), capture_output=True, text=True)
available_versions = [
parse(v) for v in re.split(r"[\n\t ]", proc.stderr)
if v and v.startswith(nodejs_version)
]
subprocess.run(split(f"nodeenv env --node={max(available_versions)} --prebuilt"))
subprocess.run(f". env/bin/activate && npm install --no-fund .", shell=True)
but it would be nice if nodeenv could do this for you