~ac/chnode

A crufty Node.js version switcher (Please help me get better at C - pepehands)
a6d6a553 — Ant Cosentino 9 months ago
experimenting with zig build system
a31b3e57 — Ant Cosentino 10 months ago
add check for command processor, resolve todo, handle other command processor errors
d37f14a7 — Ant Cosentino 10 months ago
fix log line

clone

read-only
https://git.sr.ht/~ac/chnode
read/write
git@git.sr.ht:~ac/chnode

You can also use your local clone with git send-email.

#chnode

#Todos

  • Finish Windows support
  • Provide binaries for as many architectures as possible

#Installing

  • Ensure you have libcurl downloaded and reachable by your system's linker
  • make install PREFIX=/parent/directory/of/your/bin/directory

#Background

The, supposedly, best tools for this problem all seem to come with frustrating caveats.

There's nvm, but to use it you have to source it into your shell with something like:

[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"
[ -s "/usr/local/opt/nvm/etc/bash_completion" ] && . "/usr/local/opt/nvm/etc/bash_completion"

Having to manually (and even automatically) perform this step is disappointing. In no way whatsoever is this better than having a $PATH-searchable executable for doing the job. Some computers can't do this shell set-up step quickly, either, adding noticable delay for booting new shells. It even has the side-effect of polluting the shell with loads of functions that are never used. Then there's the problem with how nvm updates itself. That is to say, it's outright broken in one particularly popular OS configuration. I do like how it can interpret release names like lts/carbon, though, and have it find the URL to the correct binary. That isn't an easy feature to provide. And how it uses rc files in projects, which is by far my favourite feature.

I tried to find other popular tools and came across nvs, which is actually written in JavaScript. Really missing the point there, folks. Facepalm.

So, with all of that in mind, what I'm building here:

  • Only depends on libcurl
  • Supports major operating systems
  • Downloads the version of Node.js you specify (only with a version number, right now, unfortunately)
  • Symlinks it to somewhere on your $PATH
  • Keeps all the tarballs and binaries downloaded in your home directory (~/.chnode/$version); and
  • Is just a single executable with no ahead-of-time set-up required, or complicated update flow (cough, nvm)