-
Notifications
You must be signed in to change notification settings - Fork 162
Description
Describe the Bug
In short: When asdf is installed with homebrew, installing nodejs packages globally will send them to /opt/homebrew instead of ~/.asdf
I don't recall seeing this issue under 0.16.0 so I think it could be 0.17.0 related, but I just upgraded to 0.17.0 and updated nodejs plugin, installed newest node LTS version (22.15.1), but am unable to install yarn globally under ~/.asdf.
Trying to call yarn after installing it (npm install -g yarn) results in it getting installed in /opt/homebrew/bin. (I have other dependencies installed with homebrew that installed a system node/npm under homebrew, but asdf is first in my $PATH so it takes priority)
Steps to Reproduce
(with clean system, i.e. no ~/.asdf yet)
brew install asdfasdf plugin add nodejsasdf install nodejs 22.15.1which npm=>/Users/kieran/.asdf/shims/npmwhich yarn=>yarn not foundnpm install -g yarnls -la ~/.asdf/shims/(no yarn)asdf reshimls -la ~/.asdf/shims/(still no yarn)which yarn=>/opt/homebrew/bin/yarnnpm root -g=>/opt/homebrew/lib/node_modulesnpm list -g
/opt/homebrew/lib
├── corepack@0.32.0
├── npm@11.4.0
└── yarn@1.22.22
Expected Behaviour
Installing using the asdf installed npm should install global packages under ~/.asdf folder
Actual Behaviour
It's installing into /opt/homebrew because the asdf installed npm is picking up homebrew npmrc:
› ~/.asdf/shims/npm config ls
; "builtin" config from /opt/homebrew/lib/node_modules/npm/npmrc
prefix = "/opt/homebrew"
; node bin location = /Users/kieran/.asdf/installs/nodejs/22.15.1/bin/node
; node version = v22.15.1
; npm local prefix = /Users/kieran
; npm version = 11.4.0
; cwd = /Users/kieran
; HOME = /Users/kieran
; Run `npm config ls -l` to show all defaults.
Note the prefix pointing to /opt/homebrew even though I have called the asdf npm. The result is that asdf shims never contains yarn binary, and when running multiple version of nodejs with asdf, this means all global packages for different nodejs versions are installed to the some /opt/homebrew location
Environment
OS:
Darwin Kierans-MacBook-Pro.local 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:29 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6030 arm64
SHELL:
zsh 5.9 (arm64-apple-darwin24.0)
BASH VERSION:
3.2.57(1)-release
ASDF VERSION:
0.17.0 (revision unknown)
ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/Users/kieran/.asdf
ASDF_CONFIG_FILE=/Users/kieran/.asdfrc
ASDF INSTALLED PLUGINS:
nodejs https://github.com/asdf-vm/asdf-nodejs.git
fd2c7f94c4c71416047ca