简体   繁体   中英

React Native - Command PhaseScriptExecution failed with a nonzero exit code xcode setup error

I facing an issue in running a react native project. enter image description here

I am confronted with this line

bash: Projects/Party-App/node_modules/react-native/scripts/../Libraries: No such file or directory Command PhaseScriptExecution failed with a nonzero exit code

On both VSCode and Xcode, already tried installing, uninstalling npm and react-native etc. Have also tried excluding x64 from the build settings but nothing helped.

Applying the commit that removes the find-node.sh script with patch-package fixed this issue for a dev on our team who was stuck with this issue.

The contents of our patch is simply

diff --git a/node_modules/react-native/scripts/find-node.sh b/node_modules/react-native/scripts/find-node.sh
deleted file mode 100755
index 5d6d2c4..0000000
--- a/node_modules/react-native/scripts/find-node.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/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"
-
-# Source nvm with '--no-use' and then `nvm use` to respect .nvmrc
-# See: https://github.com/nvm-sh/nvm/issues/2053
-if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
-  # shellcheck source=/dev/null
-  . "$HOME/.nvm/nvm.sh" --no-use
-  nvm use 2> /dev/null || nvm use default
-elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
-  # shellcheck source=/dev/null
-  . "$(brew --prefix nvm)/nvm.sh" --no-use
-  nvm use 2> /dev/null || nvm use default
-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
diff --git a/node_modules/react-native/scripts/react-native-xcode.sh b/node_modules/react-native/scripts/react-native-xcode.sh
index 3ef9a71..304a5dc 100755
--- a/node_modules/react-native/scripts/react-native-xcode.sh
+++ b/node_modules/react-native/scripts/react-native-xcode.sh
@@ -79,9 +79,7 @@ if [[ $DEV != true && ! -f "$ENTRY_FILE" ]]; then
   exit 2
 fi
 
-# Find path to Node
-# shellcheck source=/dev/null
-source "$REACT_NATIVE_DIR/scripts/find-node.sh"
+NODE_BINARY="$(command -v node)"
 
 # check and assign NODE_BINARY env
 # shellcheck source=/dev/null
diff --git a/node_modules/react-native/scripts/react_native_pods.rb b/node_modules/react-native/scripts/react_native_pods.rb
index 1b8a078..d65c9ca 100644
--- a/node_modules/react-native/scripts/react_native_pods.rb
+++ b/node_modules/react-native/scripts/react_native_pods.rb
@@ -289,8 +289,6 @@ else
 fi
 
 find_node () {
-  source "$RN_DIR/scripts/find-node.sh"
-
   NODE_BINARY="${NODE_BINARY:-$(command -v node || true)}"
   if [ -z "$NODE_BINARY" ]; then
     echo "error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable." >> "${SCRIPT_OUTPUT_FILE_0}" 2>&1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM