mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
6334ac35ac
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 <!-- Help reviewers and the release process by writing your own changelog entry. For an example, see: https://github.com/facebook/react-native/wiki/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` <img width="493" alt="Screen Shot 2021-06-17 at 10 14 08 AM" src="https://user-images.githubusercontent.com/2659478/122413946-c2f57200-cf54-11eb-817c-bd3c07ac50bf.png"> Reviewed By: yungsters Differential Revision: D31237363 Pulled By: charlesbdudley fbshipit-source-id: 4ee9c04f8b8ab4e815bafbe2d02e589d621577b4
53 lines
1.6 KiB
Bash
Executable File
53 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This source code is licensed under the MIT license found in the
|
|
# LICENSE file in the root directory of this source tree.
|
|
|
|
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
|
|
export PATH="$HOMEBREW_M1_BIN:$PATH"
|
|
fi
|
|
|
|
# Define NVM_DIR and source the nvm.sh setup script
|
|
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"
|
|
|
|
if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
|
|
# shellcheck source=/dev/null
|
|
. "$HOME/.nvm/nvm.sh"
|
|
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
|
|
# shellcheck source=/dev/null
|
|
. "$(brew --prefix nvm)/nvm.sh"
|
|
fi
|
|
|
|
# Set up the nodenv node version manager if present
|
|
if [[ -x "$HOME/.nodenv/bin/nodenv" ]]; then
|
|
eval "$("$HOME/.nodenv/bin/nodenv" init -)"
|
|
elif [[ -x "$(command -v brew)" && -x "$(brew --prefix nodenv)/bin/nodenv" ]]; then
|
|
eval "$("$(brew --prefix nodenv)/bin/nodenv" init -)"
|
|
fi
|
|
|
|
# Set up the ndenv of anyenv if preset
|
|
if [[ ! -x node && -d ${HOME}/.anyenv/bin ]]; then
|
|
export PATH=${HOME}/.anyenv/bin:${PATH}
|
|
if [[ "$(anyenv envs | grep -c ndenv )" -eq 1 ]]; then
|
|
eval "$(anyenv init -)"
|
|
fi
|
|
fi
|
|
|
|
# Set up asdf-vm if present
|
|
if [[ -f "$HOME/.asdf/asdf.sh" ]]; then
|
|
# shellcheck source=/dev/null
|
|
. "$HOME/.asdf/asdf.sh"
|
|
elif [[ -x "$(command -v brew)" && -f "$(brew --prefix asdf)/asdf.sh" ]]; then
|
|
# shellcheck source=/dev/null
|
|
. "$(brew --prefix asdf)/asdf.sh"
|
|
fi
|