| The rest of the world handles that through PATH/PATH equivalent. Either the package manager is invoked with a different PATH (one that contains the desired Node/Java/whatever version as a higher priority item than any other
version on the system). Or the package manager itself has some way to figure that out through its config file. Or there is a package manager launch tool, just like pyenv or whatever, which does that for you. In practice it's not that a big of a deal, even for Maven, a tool created 21 years ago. As the average software dev you figure that stuff out a few weeks into using the tool, maybe you get burnt a few times early on for misconfiguring it and then you're on autopilot for the rest of your career. Wait till you hear about Java's CLASSPATH and the idea of having a SINGLE, UNIFIED package dependency repo on your system, with no need for per-project dependency repos (node_modules), symlinks, or all of that stupidity. CLASSPATH was introduced by Java in 1996, I think, and popularized for Java dependency management in 2004. |
Activating a venv is just setting a few environment variables, including PATH, and storing the old values so that you can put them back to deactivate the environment.