Hacker News new | ask | show | jobs
by mmoustafa 163 days ago
I don't think 0.38s is a bad trade-off for convenience when the rest of the tools I need to do my job collectively are another 2s at shell startup. NVM alone adds 0.5-0.6s on my M4 Macbook Air.

Bigger fish to fry if we're being practical.

4 comments

You can replace nvm with https://mise.jdx.dev/ , it starts effectively instantly and works not only for node versions but all programming languages and tools.

`mise use node@latest`

or asdf
I'm using Asdf too. Have heard well about Mise, but I haven't figured out what the difference is, so I have stayed with Asdf
mise has more features - it is a super set of asdf. For example it can set your env vars when you cd into a directory (like direnv). It also has tasks (which I haven't used) - they appear to be similar to what a Makefile does. So you can potentially replace three tools (asdf, direnv, make) with one.
Thanks! Sounds interesting!
Mise started out using the same plugins as asdf, mostly focused on adding performance and usability improvements. Over time it added more features and security.

Most tools are now directly fetched from github releases without the need for random shell scripts (which is what asdf plugins are).

It also grew to be a task runner and environment manager. At first you might think this is scope creep but they're both opt in and very elegant additions. I don't want to ramble but let's just say they've solved real problems I've had.

I'm a fan of it, and I can't think of a reason why I would use asdf over mise. Its real competition is nix (+devbox/devenv/flox), devcontainers, and pixi.

I will check it out! Thanks for the explanation! Sounds really neat
I am seeing a phenomenon of people wanting to hyper optimise their workflows. It’s nonsensical when you consider the other stuff you need to do or how slow everything else is.
Holy heck, I just profiled my zsh initialization and nvm was the big source of bloat, holy hell. Similar setup as you (M4 MBP), same amount of startup bloat. Lazy loading it fixes it.

GPT-5.2 changed the nvm initialization script to:

  export NVM_DIR="$HOME/.nvm"
  
  _nvm_lazy_load() {
  unset -f nvm node npm npx _nvm_lazy_load
  [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
  }
  
  nvm() { _nvm_lazy_load; nvm "$@"; }
  node() { _nvm_lazy_load; command node "$@"; }
  npm() { _nvm_lazy_load; command npm "$@"; }
  npx() { _nvm_lazy_load; command npx "$@"; }
That's why I switched to Mise (https://mise.jdx.dev). Having new terminal sessions taking up hundreds of milliseconds because of nvm isn't the end of the world, but it's annoying when you're in the middle of something.

Mise reads in your .nvmrc files so you don't have to configure anything new.

Although this is what Opus recommends, it will give you many issues as you don’t really have any node runtimes in the path (or worse if you do).

What I recommend is replacing it with $PATH=(a command to find the nvm default alias directory, detect the verion and load it from that specific version directory directly) so you always have default node in path and then lazy loading only nvm itself, so you can switch when you need to.

Sorry I don’t have the command handy as I’m on mobile but if you paste the above into Opus you’ll get it.

Thanks. I modified my comment to disclose that gpt 5.2 generated that modification. I'll try your suggestion.
..have you checked. It's 0.04s in my setup. I have it a bit customized but I don't remember chasing milliseconds on config