To ensure we're using the right version of Nodejs locally, especially when switching between projects and repositories, we can use asdf.
These instructions are a summary of those found on asdf's Getting Started guide.
brew install asdf
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
asdf install nodejs 18.7.0
asdf local nodejs 18.7.0
From here you can install Node dependencies with Yarn.
brew install yarn
If you encounter unrecognised versions of node after adding them to asdf you may need reinstall yarn for node re-shims to be recognised:
npm install -g yarn