- Elliot DeNolf
This article will go through basic asdf configuration for Node.js, including how asdf can read from existing .nvmrc files.
Why switch from nvm?
Multiple language support
asdf supports multiple langauges. This allows me to learn one version manager for all of them. Every languages has their own preferred language manager, and they all vary slightly. Learning a single version manager and its commands just makes sense
Automatically change versions for current directory
asdf automatically changes node version based upon a directory's
.nvmrc (with configuration). Though this can be done with nvm in conjuction with some additional bash scripting. I found the solution rather cumbersome, and the actual usage introduces quite a bit of latency when changing into a directory and the script running
nvm use in the background.
With asdf, this all goes away, and it just works and is instant.
brew install asdf
asdf plugin add nodejs
Install a node version
To view all available versions using this command
asdf list all nodejs
Choose a specific version or use the
asdf install nodejs latest
asdf global nodejs latest
Allow asdf to read .nvmrc files
echo 'legacy_version_file = yes' > ~/.asdfrc
Configure yarn for global packages with asdf
yarn config set prefix ~/.yarn
This will let yarn know where to find global packages that were installed with asdf.
Completions can be installed using this plugin.
There is also an oh-my-zsh plugin available.