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.
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 "$@"; }..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
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`