score:-4

I tried a lot of solutions nothing works for me except removing nvm

rm -rf ~/.nvm

score:-1

Selecting a node version helped in my case: nvm use x.x.x.

I had this issue when starting the build with yarn - and was able to build the app only by using xcode or react-native run-ios.

score:-1

So, I had the following error in the console when trying to run ios:

error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:

  • react-native-flipper (to unlink run: "react-native unlink react-native-flipper") [...]

I fixed it by tweaking my react-native.config.js like below and react-native run-ios started worked again

module.exports = {
  dependencies: {
    'react-native-flipper': {
      platforms: {
        ios: null, // Disable autolinking on iOS
      },
    },
  },
};

score:-1

I was installing TheCodingMachine React Native boilerplate 3.2.5 link and I got a similar error.

Decision. Updated the React Native version

//react-native": "0.66.4" ->  "react-native": "0.67.3"

cd ios && rm -rf Pods && pod install

And an nvm update can also help.

score:-1

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

score:0

Add below line in a pod file 1) use_flipper!({ 'Flipper-Folly' => '2.5.3', 'Flipper' => '0.87.0', 'Flipper-RSocket' => '1.3.1' })

  1. delete pod folder and lock.

  2. pod install

  3. run the app from Xcode and later from vscode.

score:0

For Final Run Mac 1 Silicon 0.65 (any version)

Npx react-native init newproject

Then change the pod file

Go to

Cd iOS

Open pod file

Add

platform :ios, '12.1'


  use_flipper!()
  post_install do |installer|
    react_native_post_install(installer)
        installer.pods_project.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] =  "arm64"
        end
  end

Pod File

And bridge header by adding the new swift file and after addition of bridge header please delete the swift file otherwise swift file may generate error.

For Creating the Swift File.

Go to project nitin2 -> Nitin2 (sub project) and right click on it Click New File Select swift file -> next Then select the nitin2 directory in the iOS folder Leave the file name same Click checkbox nitin2 in the target Click create Now the it will ask to create the bridging header.h Yes create the file And now go to

Go to project nitin2 -> Nitin2 (sub project) See the file.swift and delete it.

Now go to Xcode -> target Nitin2 -> build setting In ARCHITECTURES CLICK EXCLUDED ARCHITECTURES AND ADD THE arm64

Xcode

Now Remove the build folder from Xcode product menu

Now do the things through terminal

Cd go to iOS directory

pod cache clean --all  

yarn cache clean  

rm -rf ~/Library/Developer/Xcode/DerivedData/*

open nitin2.xcworkspace

rm -rf Pods Podfile.lock 


pod deintegrate && pod setup && pod install

code /Users/nitin/D1/www/projects/nitin2/ios/Pods/../../node_modules/react-native/React/FBReactNativeSpec/../../scripts/generate-specs.sh

Add export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin

Then run the iOS

npx react-native run-ios 

score:0

Copy all the script in xcode print and debug it in your shell. Using set -x to debug in shell. Normally you will find the actual bug.

PhasescriptExecution: strong text if ~/.nvmrc exists, but nvm is not a cmd in you shell.

score:0

If you do want to keep with nvm, you can comment the code from node-modules/react-native/scripts/find-node.sh related to search the node version and add after it like:

export PATH="/Users/myMacUser/.nvm/versions/node/v16.13.0/bin/:$PATH"

in my case i commented these lines:

# # 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

on Xcode Build Phases I set statically the node version too on Bundle React Native code and images

set -e

export NODE_BINARY=/Users/myMacUser/.nvm/versions/node/v16.13.0/bin/node
../node_modules/react-native/scripts/react-native-xcode.sh

myMacUser is your user

v16.13.0 is the node version I am using, you can set the one you want.

score:0

I have a lot of trouble trying to build an App, just to realize that my node installation isn't "normal". So, to make this work, I just linked the node to the usr/local/bin folder.

sudo ln -s $(which node) /usr/local/bin/node

Running on a Mac M1.

score:0

If you are using nvm with an intel based Mac ln -s $(which node) /usr/local/bin should take care of the issue.

score:1

PLEASE READ THE COMMENTS AS WELL

For me, this worked as I didn't have time to wait for answers (Not recommended method but if nothing else is working can go for this):

I uninstalled npm, node, and react-native and upon installing them again everything is working.

score:1

I followed https://github.com/react-native-community/upgrade-support/issues/138#issuecomment-808895860

After two days of trying i found the solution in deleting spaces in the path where your project lives and run. But in order for this to work properly follow these steps:

  • If you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues (i.e. npm uninstall -g react-native-cli)
  • Move the project folder in a path with no spaces (i.e. ~/sub folder name/ReactNativeApp won't work till you have spaces in the path, so move in a path like ~/folder/ReactNativeApp)
  • Then cd into the project folder and upgrade react native to the latest version with npx react-native upgrade and resolve conflicts if any
  • After upgrading remove the node_modules folder and the yarn.lock from the root and the podfile.lock and Pods folder from ios subfolder
  • Then cd back to the root and run yarn install && npx pod-install

Now run again your app in Xcode or your IDE and it works

Crazy and absurd that a space in the path-name could cause this issue

Thanks giuseppealbrizio!

I think my core fix came from running npx pod-install which update my Pod.lock checksum.


Versions:

  • React-Native: 0.64.2
  • iOS Emulator: 14.4
  • XCode: 12.5

On a brand new npx react-native init project

score:2

  1. Build Settings -> Build Active Architecture Only -> Debug -> Yes
  2. Add "arm64" in "Excluded Architectures" in build settings of both project and pods project, to run the app in simulator. Remove it while making build on device or archiving the app.

score:2

If you use nvm make sure that you don't have separate node installed globally.

Check this answer for more https://stackoverflow.com/a/67035460/6653922

score:2

I got past this by removing nvm and reinstalling afterwards. I also removed the check lines from my .zshrc

rm -rf ~/.nvm

score:3

I think your problem come from this line.

The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.4.99.

This warning means that you are trying to deploy on a version that is not supported by Xcode anymore.

Your react native package seems to not be up to date because it init your project with the wrong target.

Use 'npx react-native init ProjectName' to fix this problem. This command will execute react-native with the latest version online.

You can fix your project target by using this command from this post.

When you run react-native run-ios, react-native will try to deploy with the target in his config file, but on Xcode the problem is bypassed by the config in Xcode.

score:3

in my case, just run rm -rf ./Pods && pod install, and then build your app npx react-native run-ios

score:5

Thank you @Neil Hasen for the detailed explanation. Instead of uninstalling nvm because I use it in a number of projects, I simply commented out the code in ./node_modules that referenced the 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

The code can be found in node_modules/react-native/scripts/find-node.sh

score:12

The problem is because you have the project created inside a folder with a name that contains spaces, example: "React Native", rename your folder to "React-Native" and rerun the command npx react-native run-ios, that should be enough.

When you execute the command npx react-native run-ios it may create a new folder for you, you must delete the folder that was generated automatically and keep the folder that you renamed at the beginning as "React-Native". Once the automatically generated folder is deleted, run the command again: npx react-native run-ios

Remember: Do not create React Native projects inside folders that contain spaces between their names.

I hope to be helpful. Greetings.

score:14

I'm running my React Native app on m1 and my problem was with nvm which I set the default alias. I just run the nvm unalias default and it solved the issue.

score:22

I've been trying to solve this problem for days on MacOS M1 Big Sur. Nobody else's exact solution worked for me, so I'm going to describe how I came to my solution. Hopefully the process will help someone else figure out what works for them.

Everything (for me) needed to be running in Rosetta. Make sure Xcode is running in Rosetta. Make sure your Terminal is running in Rosetta. Make sure pod, yarn, npm, whatever you use, is running the x86 version, not the arm64 version. Make sure you ran yarn install/npm install/pod install with the x86 versions, not the arm64 versions.

To clarify arm64 vs. x86, you should ask your Terminal which yarn, which node, which npm, which pod to see the full path to those executables. This is complicated by there being so many ways to install node. I installed node through Homebrew, so my paths below reflect that.

For Homebrew on x86 (running in Rosetta Terminal), you should see:

$ which node
/usr/local/homebrew/bin/node
$ which yarn
/usr/local/homebrew/bin/yarn
$ which npm
/usr/local/homebrew/bin/npm

Note the /usr/local/homebrew/bin. If you're not running in Rosetta Terminal, you'll see /opt/homebrew/bin. If you're seeing /opt/homebrew/bin anywhere, it's a red flag.

Another trap, easy to fall into... I was in Rosetta Terminal with the x86 node, but I realized that my global yarn installation was /opt/homebrew/bin/yarn. I was doing yarn install with arm64 yarn, which can cause problems with your dependencies.

Seriously, run all the commands above as a sanity check.

Things still weren't working. Same error in Xcode, a mysterious PhaseScriptExecution error on some FBReactNativeSpec.build/Script-********.sh. I opened up Script-********.sh, and saw that it called node_modules/react-native/scripts/generate-specs.sh, which in turned called another script find-node.sh.

find-node.sh led me to my problem. I put "echo" debugging statements all over it, and then I ran find-node.sh directly to see what was printed. Sure enough, this one caught something:

elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
  echo "AM I GOING CRAZY?"
  . "$(brew --prefix nvm)/nvm.sh"
fi

I have no idea what this script is doing, but back in my Terminal I ran echo $(brew --prefix nvm), which output /usr/local/homebrew/opt/nvm. Clearly, the react-native script is making some kind of decision based on its finding nvm.

I don't want nvm to be part of my equation at all; I'm not using it. So in both Rosetta Terminal and Terminal, I brew uninstall nvm.

Back in XCode, clean build folder, rebuild, and it works.

This is not going to be a satisfying answer for many, as these exact steps will likely not work for you. No one else's exact steps worked for me.

After reading dozens of solutions to this problem, it seems that most of them have causes that are node version/path/architecture related. I hope this answer gives you some tools to investigate that yourself. Namely:

  1. Make sure which node/yarn/npm is pointing to the correct x86 path.
  2. Make sure you installed your node_modules with the correct x86 executable.
  3. Debug your node_modules/react-native/scripts/find-node.sh to see if you're tripping up on any extraneous node things in your environment.

Related Query

More Query from same tag