fix(install): use node-gyp from homebrew npm #4994
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
With this
yarn
will be able to discover and use thenode-gyp
from the homebrew installednpm
on macOS instead of falling back to globally installingnode-gyp
every time a native addon needs to be compiled from source.Homebrew installs a clean copy of
npm
inside alibexec
folder together withnode
. Previously yarn didn't look there when trying to locatenode-gyp
and theglobally install node-gyp
-fallback would be used every time when building native addons with a yarn version from homebrew.This PR adds the
libexec
path ofnode-gyp
from homebrew to thenode-gyp
search paths of yarn, making it possible to compile native addons using the homebrew npm providednode-gyp
with yarn without relying on this fallback.Test plan
This can't be tested outside a homebrew environment (with node installed by homebrew, not by a node version manager like nvm).
To manually test this on a mac with homebrew installed you can install a test build of this PR (uploaded to github releases on my fork) by installing this gist
yarn
formula with:After this you can delete your global
node-gyp
and install any native addon (withyarn config set build-from-source
set to skip prebuild / node-pre-gyp) and verify that no new globalnode-gyp
is installed. You could also look at the verbose install output to verify, that the fallback isn't used this time. You can also verify with the current homebrew version of yarn, that the global node-gyp fallback is used every time when building native addons from source until now.