From e0b9991a8c0fa415998a3216249d7cf9dfbc7315 Mon Sep 17 00:00:00 2001 From: Michael Neeley Date: Thu, 30 Sep 2021 15:00:27 -0700 Subject: [PATCH] Fixes Global Node Prefix Error (#31740) Summary: Some users have `node` installed globally which sets a `PREFIX` by default (so it knows where to put pkgs). We are looking for the "right" node on the next step anyway and if the user is using `nvm`, `PREFIX` breaks it. closes https://github.com/facebook/react-native/issues/31181 ## Changelog [General] [Fixed] - Ignores global npm prefix Pull Request resolved: https://github.com/facebook/react-native/pull/31740 Test Plan: `yarn ios` now works, even if there's a `usr/local/bin/npm` Screen Shot 2021-06-17 at 10 14 08 AM Reviewed By: yungsters Differential Revision: D31237363 Pulled By: charlesbdudley fbshipit-source-id: 4ee9c04f8b8ab4e815bafbe2d02e589d621577b4 --- scripts/find-node.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/find-node.sh b/scripts/find-node.sh index 69e6ac232576cd..1f7345b61cac34 100755 --- a/scripts/find-node.sh +++ b/scripts/find-node.sh @@ -6,6 +6,10 @@ set -e +# remove global prefix if it's already set +# the running shell process will choose a node binary and a global package directory breaks version managers +unset PREFIX + # Support Homebrew on M1 HOMEBREW_M1_BIN=/opt/homebrew/bin if [[ -d $HOMEBREW_M1_BIN && ! $PATH =~ $HOMEBREW_M1_BIN ]]; then