[asdf Node.js] Use asdf nodejs plugin to install multiple Node.js versions
asdf and Node.js Plugin
asdf
is a single CLI tool for managing multiple runtime versions. It extend with a simple plugin system to install your favourite language: Dart, Elixir, Flutter, Golang (Go), Java, Node.js, Python, Ruby …
This article is about how to use asdf
and Node.js plugin to install multiple Node.js versions on macOS with the Homebrew package manager.
Prerequisites
-
Xcode Command Line Tools
The Xcode Command Line Tools Package is a small self-contained package available for download separately from Xcode and that allows you to do command line development in macOS which is consists of the macOS SDK and command-line tools such as Clang, which are installed at thisFor more information about installing and using Xcode Command Line Tools, see the Xcode Command Line Tools
-
Homebrew
Homebrew is the Missing Package Manager for macOS (or Linux).For more information about installing and using Homebrew, see the Homebrew - https://brew.sh/.
Installation
Install asdf
1 | Install asdf dependencies |
asdf Node.js Plugin
1 | Install Node.js plugin requirements |
Add to your Shell
Add asdf.sh
to your ~/.zshrc
with:
1 | echo -e "\n. $(brew --prefix asdf)/asdf.sh" >> ${ZDOTDIR:-~}/.zshrc |
Or see Add to your Shell - https://asdf-vm.com/#/core-manage-asdf to learn when you use other shells.
List all Node.js Version
Update Node.js plugin.
1 | asdf plugin update nodejs |
List all Node.js versions.
1 | asdf list all nodejs |
Install Node.js version
Install a Node.js version manually.
1 | asdf install nodejs 14.8.0 |
Or install another version.
1 | asdf install nodejs 14.0.0 |
FAQs
cat: /usr/local/VERSION: No such file or directory
Add asdf.sh
to your ~/.zshrc
to resolve it
1 | echo -e "\n. $(brew --prefix asdf)/asdf.sh" >> ${ZDOTDIR:-~}/.zshrc |
OR see Add to your Shell - https://asdf-vm.com/#/core-manage-asdf to learn when you use other shells.
You must install GnuPG to verify the authenticity of the downloaded archives before continuing with the install: https://www.gnupg.org/
Install GnuPG to resolve it.
1 | GnuPG |
No preset version installed for command yarn or No yarn executable found for nodejs 16.7.0
1 | yarn -v sit 10:23:23 |
Or
1 | yarn -v |
Check node
, yarn
status.
1 | which node 10:32:12 |
Check yarn
reshime shell.
1 | cat /Users/cloudolife/.asdf/shims/yarn |
Install global yarn
.
1 | npm i -g yarn |
References
[1] Manage asdf - https://asdf-vm.com/#/core-manage-asdf