Skip to content

bug: npm install -g yarn install location not going to ~/.asdf #423

@KieranP

Description

@KieranP

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)

  1. brew install asdf
  2. asdf plugin add nodejs
  3. asdf install nodejs 22.15.1
  4. which npm => /Users/kieran/.asdf/shims/npm
  5. which yarn => yarn not found
  6. npm install -g yarn
  7. ls -la ~/.asdf/shims/ (no yarn)
  8. asdf reshim
  9. ls -la ~/.asdf/shims/ (still no yarn)
  10. which yarn => /opt/homebrew/bin/yarn
  11. npm root -g => /opt/homebrew/lib/node_modules
  12. npm 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Go asdf (0.16+)Related to asdf-core migration to golangneeds investigationAn issue that needs to be investigated

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions