I installed node.js:
brew install node
I also installed asdf with node.js plugin. Is there any way to use node.js installed via Homebrew globally if there is no .tool-versions file?
Right now I am getting an error if this file does not exist:
No version is set for command node
Consider adding one of the following versions in your config file at
nodejs 19.0.0
nodejs 19.0.1
nodejs 19.1.0
nodejs 19.2.0
I don't want to use asdf globally. Just for few projects.
It doesn't completely answer your question, but I've stumbled upon the same problem and found the following workaround for using
asdfwith some projects, but not others:Instead of sourcing the asdf scripts for every shell, I wrap them in a condition.
~/.bashrc(on Linux & Bash, in your case it will probably be${ZDOTDIR:-~}/.zshrc) might then contain the following:With this asdf is initially not loaded at all and I can use NVM like before (or, in your case, the system's nodeJS). By simply typing
asdfinto the terminal, a new shell is invoked with asdf loaded. To return to the non-asdf shell a simpleexit(or Ctrl+D) will do.(Obviously you'll have to adjust the above for your specific environment, i.e. Homebrew and probably ZSH, based on these code samples from asdf's getting started page.)
If you prefer, you could turn this principle around and make asdf the default (with some extra steps included that only apply if you use NVM) (untested):
You could probably build on that and have a script auto-evaluate whether a
.tool-versionsfile exists in the cwd at any given time and then automatically start or exit the shell, but that's quite a bit beyond my shell-fu.