What does HackerNews think of nvm?

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions

Language: Shell

#10 in Bash
#5 in Node.js
#16 in Node.js
#13 in Shell
Awk is really great, for those knowing nvm [1], I used awk to make `nvm ls-remote` run more than 10 times faster [2] by replacing the related shell script with around 60 lines of awk script [3], and I was quite happy with the improvement.

It's not really a one-liner, neither something big, but one can take that as an example regarding that awk is really not just for one-liners.

Meanwhile having `--csv` support is really nice. I'd also like to see things like a builtin `length` function to be standard.

[1]: https://github.com/nvm-sh/nvm/ [2]: https://github.com/nvm-sh/nvm/pull/2827/ [3]: https://github.com/nvm-sh/nvm/blob/9a769630d7/nvm.sh#L1703-L...

Manage multiple npm versions at once using a node package manager manager such as:

   Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
   https://github.com/nvm-sh/nvm

   Volta - The Hassle-Free JavaScript Tool Manager
   https://volta.sh/

   asdf - Manage multiple runtime versions with a single CLI tool
   https://asdf-vm.com/
Eventually we might need a node package manager manager manager to make sure we are using the right one for a project lol
Try doing this on a 5 year old project. You'll very likely end up in dependency hell.

There is a solution though - use of nvm and .nvmrc (to control the version of node and npm that you use), and use of npm ci (which installs packages as they were at the time, rather than installing newer versions than specified in package-lock.json (because too many devs rarely ever pin versions) instead of npm install / npm i).

nvm (Node Version manager): https://github.com/nvm-sh/nvm npm ci: https://docs.npmjs.com/cli/v6/commands/npm-ci

Edit: actually just checked what's wrong again.

When running with cmd, I get an error about Python 2 being used instead of Python3:

  C:\Users\USERNAME>pip --version
  Fatal error in launcher: Unable to create process using '"c:\python27\python.exe"  "C:\Python27\Scripts\pip.exe" '
  C:\Users\USERNAME>pip --version
When running with Git Bash, I don't get any output whatsoever:

  USER@MACHINE MINGW65 ~
  $ pip --version

  USER@MACHINE MINGW65 ~
As it turns out, PATH has both Python 3 and Python 2 in it. Why is there also Python 2 on the machine? A legacy project that needs testing whilst migrating it over? Helping someone with an older script? Who even knows at this point.

My takeaways:

  1. following the first Google result (python.org and the official installer) wasn't the problem here
  2. Python 2 and Python 3 don't play nicely together, at all, might need to remove the old one from PATH to avoid headaches
  3. Specifying the Python interpreter to use (my example above, or better yet explicit python3) solved the issue
  4. Certain shells are weird sometimes, go figure
  5. What you're saying about pyenv is probably a good idea
Or maybe even something like PyCharm which lets you specify the runtime per project (much like you could specify which JDK to use with IntelliJ for Java).

Hopefully by the time Python 4 comes out and breaks everything, we'll already have figured out use cases like this (just kidding, sort of).

Node feels much the same way, especially because it moves ahead a bit more quickly with its releases and has less backwards compatibility when compared to Python. Somehow projects like Node Version Manager (https://github.com/nvm-sh/nvm) didn't really seem to gain much traction.

I am currently aware of the following Javascript "version managers":

- NVM: https://github.com/nvm-sh/nvm

- N: https://github.com/tj/n

- Volta: https://volta.sh/

- FNM: https://fnm.vercel.app/

- ASDF-VM: https://asdf-vm.com/

I started with NVM, which is so slow that I'm confused (and maybe even impressed) as to how it's possible to be so slow.

Then I switched to FNM, which is delightfully not-slow.

Then I switched to Volta, because it supports installing standalone "tools" other than just Node, like Yarn and the various LSP servers that I use. If it's slower than FNM, it's not enough slower to matter to me.

I tried N but don't use it. It seems to have a more "interactive" UI than FNM or Volta, so use N if you like that kind of thing.

I haven't used ASDF-VM, which apparently supports several languages/interpreters/compilers, including Node. I have been meaning to try it. I am somewhat skeptical that a general-purpose "do everything" tool would be better than a collection of purpose-built tools like Pyenv, Rbenv, Plenv, NVM/FNM/Volta/N, etc. etc., but people seem to really like it.

VSCode will detect virtual environments within the directory structure.

Node definitely has this issue. There's a reason Node NVM[1] exists.

[1] https://github.com/nvm-sh/nvm

Absolutely. For Node, check nvm : https://github.com/nvm-sh/nvm

And choose SQLite.