upgrade-support: FBReactNativeSpec error after upgrade from 0.63.4 to 0.64.0

Environment

System: OS: macOS 11.2.3 CPU: (8) x64 Intel® Core™ i7-4770HQ CPU @ 2.20GHz Memory: 1.27 GB / 16.00 GB Shell: 5.8 - /usr/local/bin/zsh Binaries: Node: 12.18.0 - ~/.nvm/versions/node/v12.18.0/bin/node Yarn: 1.22.10 - ~/.nvm/versions/node/v12.18.0/bin/yarn npm: 6.14.5 - ~/.nvm/versions/node/v12.18.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: API Levels: 28, 29 Build Tools: 19.1.0, 20.0.0, 21.1.2, 22.0.1, 23.0.1, 23.0.2, 23.0.3, 24.0.0, 24.0.1, 24.0.2, 24.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.2, 27.0.3, 28.0.0, 28.0.1, 28.0.2, 28.0.3, 29.0.2, 30.0.3 System Images: android-28 | Google APIs Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.7042882 Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: 1.8.0_281 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.1 => 17.0.1 react-native: 0.64.0 => 0.64.0 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Things I’ve done to figure out my issue

I used react-native cli to upgrade and the following page to manually changes. https://react-native-community.github.io/upgrade-helper/?from=0.63.4&to=0.64.0

Upgrading version

0.64.0

Description

I’ve faced the following error when I want to start the IOS app with the “react-native run-ios” command. If I start the debug build from XCode, it is started successfully.

/bin/sh -c /Users/keklikc/Library/Developer/Xcode/DerivedData/DataroidMobile-gmjqxfphavicwkcccsennxqbhvuj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-0565B84ED1A643A94B66851B97B33BAC.sh nvm is not compatible with the “npm_config_prefix” environment variable: currently set to “/Users/keklikc/.nvm/versions/node/v12.18.0” Run unset npm_config_prefix to unset it. /Users/keklikc/.zshrc: line 83: zstyle: command not found /Users/keklikc/.zshrc: line 84: zstyle: command not found /Users/keklikc/.zshrc: line 85: zstyle: command not found /Users/keklikc/.oh-my-zsh/tools/check_for_upgrade.sh: line 32: syntax error near unexpected token )' /Users/keklikc/.oh-my-zsh/tools/check_for_upgrade.sh: line 32: () {’ /Users/keklikc/.oh-my-zsh/oh-my-zsh.sh: line 21: autoload: command not found /Users/keklikc/.oh-my-zsh/oh-my-zsh.sh: line 39: syntax error near unexpected token (' /Users/keklikc/.oh-my-zsh/oh-my-zsh.sh: line 39: for plugin ($plugins); do’ /Users/keklikc/.zshrc: line 120: autoload: command not found /Users/keklikc/.zshrc: line 129: add-zsh-hook: command not found nvm is not compatible with the “npm_config_prefix” environment variable: currently set to “/Users/keklikc/.nvm/versions/node/v12.18.0” Run unset npm_config_prefix to unset it. Command PhaseScriptExecution failed with a nonzero exit code

warning: 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. (in target ‘Flipper-Glog’ from project ‘Pods’) warning: 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. (in target ‘boost-for-react-native’ from project ‘Pods’) warning: The iOS Simulator deployment target ‘IPHONEOS_DEPLOYMENT_TARGET’ is set to 8.4, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target ‘Flipper-PeerTalk’ from project ‘Pods’) warning: 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. (in target ‘YogaKit’ from project ‘Pods’) warning: no rule to process file ‘/Users/keklikc/Projects/Dataroid-MobileApp/ios/Pods/Flipper-RSocket/rsocket/README.md’ of type ‘net.daringfireball.markdown’ for architecture ‘x86_64’ (in target ‘Flipper-RSocket’ from project ‘Pods’) warning: no rule to process file ‘/Users/keklikc/Projects/Dataroid-MobileApp/ios/Pods/Flipper-RSocket/rsocket/benchmarks/CMakeLists.txt’ of type ‘text’ for architecture ‘x86_64’ (in target ‘Flipper-RSocket’ from project ‘Pods’) warning: no rule to process file ‘/Users/keklikc/Projects/Dataroid-MobileApp/ios/Pods/Flipper-RSocket/rsocket/benchmarks/README.md’ of type ‘net.daringfireball.markdown’ for architecture ‘x86_64’ (in target ‘Flipper-RSocket’ from project ‘Pods’) warning: 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. (in target ‘Flipper-DoubleConversion’ from project ‘Pods’)

** BUILD FAILED **

The following build commands failed: PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/keklikc/Library/Developer/Xcode/DerivedData/DataroidMobile-gmjqxfphavicwkcccsennxqbhvuj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-0565B84ED1A643A94B66851B97B33BAC.sh (1 failure)

Reproducible demo

Upgrade from 0.63.4 to 0.64.0 then execute react-native run-ios

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 166
  • Comments: 177 (1 by maintainers)

Commits related to this issue

Most upvoted comments

In case anyone wants to try a temporary fix that worked for me: I ended up commenting all lines inside node_modules/react-native/scripts/find-node.sh. It seems as if my node environment didn’t agree with this script. I could build and run my project on an actual device afterwards without any further issues.

I added unset PREFIX (probably unset npm_config_prefix for OP) to the top of node_modules/react-native/scripts/find-node.sh and that fixes the iOS build. If this works for you, try using patch-package to make this change sticky.

I was able to resolve this problem with node by the following commands:

  1. brew uninstall yarn
  2. npm install --global yarn

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

“rm -rf ~/.nvm” fixed my problem

this resolved all of my issues:

nvm unalias default

This must be a joke, because I used a space in the parent folder name and it got fixed when I remove

…/React Native/project -> …/ReactNative/project

adding the package manually fixed it for me. yarn add --dev react-native-codegen

Anyone else experiencing this on 0.69.4 ?

Env

System:
    OS: macOS 12.0.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 62.25 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
    Yarn: Not Found
    npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm
    Watchman: 2021.11.08.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.2 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0
    Android SDK:
      API Levels: 30
      Build Tools: 30.0.2
      System Images: android-30 | Google APIs Intel x86 Atom_64
      Android NDK: Not Found
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7784292
    Xcode: 13.1/13A1030d - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_292 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.66.3 => 0.66.3 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

What allowed me to run IOS

nvm unalias default

Got the same thing trying to upgrade from 0.64.0-rc.3 to stable 0.64.0.

  • I cleared xcode build
  • watchman watch-del-all
  • yarn start --reset-cache
  • removed Pods & Podsfile.lock
  • removed node_modules
  • changed xcode build system to Legacy and back
  • rebooted laptop

Nothing helps.

Xcode 12.4 Big Sur Intel Node 15

For me(I’m Intel mac user), the error occurred after upgrading rn from 0.66 to 0.67, and nvm alias default node fixed it.

This fixed it for me. I’m on an Intel Mac, running MacOS Monterey (v12.1) and Xcode 13.2.1

Try running nvm unalias default

My System:

  • Apple Mac Mini M1 Silicon.
  • Mac OS 11.4
  • XCode 12.5 (open with Rosetta)
  • “react”: “17.0.1”
  • “react-native”: “0.64.2”,
  • Target Build IOS 14.3

I did the following:

  • Updated Node to 16.3.0 in NVM.
  • Uninstalled the React Native CLI and Reinstalled
  • nvm unalias default
  • Deleted node_modules folders, pod folder and cleaned build in Xcode
  • Deleted everything in /Users/xxxxx/Library/Developer/Xcode/DerivedData
  • Installed all packages (npm install)
  • Updated pod repo: arch -x86_64 pod repo update
  • Installed pod packages: arch -x86_64 pod install
  • Then build successfully

(Note: arch -x86_64 only for M1 Silicon)

Hi! unset npm_config_prefix works for me!

This is my node_modules/react-native/scripts/find-node.sh 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
unset npm_config_prefix

...

I hope it could help someone…

brew uninstall yarn   
npm install --global yarn

This worked for me.

Fixed my environment by doing this:

I solved the problem by uninstalling yarn and node from my mac, which was installed by using Homebrew. After that, I installed nvm and then install node BY USING nvm.

Commands I used:

brew uninstall yarn node
nvm use
npm install --global yarn

I resolved it deleting scripts in XCode. Be careful if you do it too, because it may break something if you are using it: https://www.bswen.com/2021/04/others-ios-how-to-solve-Command-PhaseScriptExecution-failed-with-a-nonzero-exit-code.html

Facing same issue. Tried using unset PREFIX or unset npm_config_prefix to the top of node_modules/react-native/scripts/find-node.sh but no luck.

This worked for me https://github.com/facebook/react-native/issues/31180#issuecomment-822069355

Run: "yarn add --dev react-native-codegen" and rebuild IOS project

@marudy - the issue with TurboModulesRegistry is actually a different issue - I ran into it too:

https://github.com/react-native-community/upgrade-support/issues/139

The error happens if you use the wrong version of node. Try making sure you are using node 12.0.

For me(I’m Intel mac user), the error occurred after upgrading rn from 0.66 to 0.67, and nvm alias default node fixed it.

For me the issue happened on the CI. At first I tried to change the nvm and node versions on those machines but without any success. As previous comments suggested, the fix was to commented/clear everything in find-node.sh script under the path node_modules/react-native/scripts/find-node.sh.

However the CI always install npm each time a PR is running for example… So I had to write a script which does it in the post install. Might help to others as well. Here is what I did:

  1. in the package.json add the following:
"scripts": {
    ...
    "postinstall": "node postinstall.js",
}
  1. Create postinstall.js file.

  2. Here is the basic code inside that file:

const fs = require('fs-extra');
const path = require('path');
const semver = require('semver');

const rnVersion = function() {
  const rnPackageJson = require('react-native/package.json');
  return rnPackageJson.version;
}();

function cleanFindNodeScriptFileForRn64IOS() {
  const REACT_SCRIPTS_PATH = path.join('node_modules', 'react-native', 'scripts');
  const REACT_FIND_NODE_SCRIPT_PATH = path.join(REACT_SCRIPTS_PATH, 'find-node.sh');

  console.log('Clean content of find-node.sh file..');
  try {
    fs.writeFileSync(REACT_FIND_NODE_SCRIPT_PATH, '');
  } catch (e) {
    console.warn('Couldn\'t clean content find-node.sh file');
  }
}

function run() {
  console.log('Running post-install script...');

  if (semver.minor(rnVersion) === 64) {
    console.log('Detected RN version .64! Applying necessary patches...');
    cleanFindNodeScriptFileForRn64IOS();
  }
}

run();

Hope it helps!

I tried all the methods in this issue but with no luck. Finally, I commented out the whole find-node.sh, and it works.

Same here - tried all above and didn’t help. I also tried removing node executable rm /usr/local/bin/node and recreating the sym link with ln -s $(which node) /usr/local/bin/node.

What helped and got it working was to comment out the whole node_modules/react-native/scripts/find-node.sh file.

Also I’m noticing this warning, but not sure if that’s part of the issue:

nvm is not compatible with the "PREFIX" environment variable: currently set to "/usr/local"
Run `unset PREFIX` to unset it.

I’m using nvm 0.34.0 and node v14.16.0 and this is occurring since I upgraded RN from 0.63.0 to 0.64.0.

Stacktrace:

Command PhaseScriptExecution failed with a nonzero exit code

** BUILD FAILED **

The following build commands failed:
	PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/ME/Library/Developer/Xcode/DerivedData/MY_APP_NAME-ewmsjsxzyhiqoegvheyxzpsfnhsr/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/FBReactNativeSpec.build/Script-548193622655E8C0D76A7ECECEE389C2.sh

PS: I have no spaces in the project path PS2: I cleaned the derived data, yarn.lock, node_modules, Pods, Pods.lock, .xcworkspace, rebooted both mac and iPhone, prayed PS3: Just tried to upgrade nvm to 0.38.0, didn’t help, still have to comment out find-node.sh

Try running nvm unalias default

@brandonpearcy thank you for the patch, and could you please explain in plain simple english what unset PREFIX does?

Interesting. Had same issue after upgrading from 0.66 to 0.67. Tried everything, deleting & re-installing pods, re-installing node modules, alias etc. The only think to have worked in my case was changing -e to +e in node_modules/react-native/scripts/find-node.sh

Hello,

I come back 😅

My precedent comment is here https://github.com/react-native-community/upgrade-support/issues/138#issuecomment-1032782312 … But now it doesn’t work anymore 😏

But I fix the issue like that, I just comment these lines in node_modules/react-native/scripts/find-node.sh file:

# 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
#   . "$HOME/.nvm/nvm.sh"
# elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
#   . "$(brew --prefix nvm)/nvm.sh"
# fi

I think there is a problem with my nvm config so I use my node version from brew.

I hope it helps someone

My fix, for now, is to clear the script. Not proud of it but progress over perfection when you’re unblocking the build. Didn’t like the idea of removing nvm or changing the desired version.

echo '' > node_modules/react-native/scripts/find-node.sh

Thanks! Running “nvm unalias default” worked for me!

If you get the error “… generate-specs.sh: No such file or directory” it probably happens, because FBReactNativeSpec adds a new script that get’s updated when you run pod-install and uses hard coded paths afterwards.

We have our Pods folder checked into the repo, so we usually don’t run pod install, if there are no new dependencies. I realized, when I was debugging on the CI but saw my own local machine paths used there. A simple npx pod-install fixed the issue on CI.

I guess this change breaks checking in Pods folder into the git repo. We will have to run npx pod-install now after repo checkout (locally and ci). I decided to add it to a postinstall script in npm.

this resolved all of my issues:

nvm unalias default

This is the only “solution” that works for me. Thanks @jeancatarina. Do you know why this happen?

I have a solution that works but is not permanent if you redo pod install 😔

In Xcode select Pods >>>FBReactNativeSpec >>> Build phases >>> Just move the CP-USER scripts before the Headers script.

When are you going to fix this?

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

it works man, it was the space

This same error also happens for peeps who have node installed through Homebrew on Apple Silicon. This complicates things since Homebrew on Apple Silicon never links to /usr/bin or /usr/local/bin. Instead, $PATH is extended by executing eval "$(/opt/homebrew/bin/brew shellenv)" in ~/.zprofile, which is not picked up by Xcode. I solved the issue in the following way:

  1. Determine what your node binary is:
$ which node
/opt/homebrew/bin/node
  1. Add a fixer function in your Podfile:
def fix_fb_react_native_spec(installer)
  installer.pods_project.targets.each do |target|
    if target.name == 'FBReactNativeSpec'
      target.build_configurations.each do |config|
        if config.name == 'Debug' or config.name == 'Release'
          config.build_settings['NODE_BINARY'] = '/opt/homebrew/bin/node'
        end
      end
    end
  end
end
  1. In your postinstall, add fix_fb_react_native_spec(installer) like so:
  post_install do |installer|
    react_native_post_install(installer)
    fix_fb_react_native_spec(installer)
  end
  1. Pod install
  2. Rebuild (ideally with a clean build)

I tried all the methods in this issue but with no luck. Finally, I commented out the whole find-node.sh, and it works.

UPDATE: I solved the problem by uninstalling yarn and node from my mac, which was installed by using Homebrew. After that, I installed nvm and then install node BY USING nvm. IT’s WORKS! NEVER TRUST HOMEBREW

Install nodejs with nvm: https://heynode.com/tutorial/install-nodejs-locally-nvm

p.s. My OS version is MacOS Big Sur 11.2.3

Try running nvm unalias default

My System:

  • Apple Mac Mini M1 Silicon.
  • Mac OS 11.4
  • XCode 12.5 (open with Rosetta)
  • “react”: “17.0.1”
  • “react-native”: “0.64.2”,
  • Target Build IOS 14.3

I did the following:

  • Updated Node to 16.3.0 in NVM.
  • Uninstalled the React Native CLI and Reinstalled
  • nvm unalias default
  • Deleted node_modules folders, pod folder and cleaned build in Xcode
  • Deleted everything in /Users/xxxxx/Library/Developer/Xcode/DerivedData
  • Installed all packages (npm install)
  • Updated pod repo: arch -x86_64 pod repo update
  • Installed pod packages: arch -x86_64 pod install
  • Then build successfully

(Note: arch -x86_64 only for M1 Silicon)

this worked for me, because I was setting an aliases for my node version earlier

I was able to resolve this problem with node by the following commands:

  1. brew uninstall yarn
  2. npm install --global yarn

Thanks, saved my day!

Below patch-package fixed this issue

diff --git a/node_modules/react-native/scripts/find-node.sh b/node_modules/react-native/scripts/find-node.sh
index c111e70..1b3ea55 100755
--- a/node_modules/react-native/scripts/find-node.sh
+++ b/node_modules/react-native/scripts/find-node.sh
@@ -4,6 +4,8 @@
 # This source code is licensed under the MIT license found in the
 # LICENSE file in the root directory of this source tree.
 
+unset npm_config_prefix
+unset PREFIX
 set -e
 
 # Define NVM_DIR and source the nvm.sh setup script

worked for react-native run-ios still issue while building for device or Archive

Below patch-package fixed this issue

diff --git a/node_modules/react-native/scripts/find-node.sh b/node_modules/react-native/scripts/find-node.sh
index c111e70..1b3ea55 100755
--- a/node_modules/react-native/scripts/find-node.sh
+++ b/node_modules/react-native/scripts/find-node.sh
@@ -4,6 +4,8 @@
 # This source code is licensed under the MIT license found in the
 # LICENSE file in the root directory of this source tree.
 
+unset npm_config_prefix
+unset PREFIX
 set -e
 
 # Define NVM_DIR and source the nvm.sh setup script

I added unset PREFIX (probably unset npm_config_prefix for OP) to the top of node_modules/react-native/scripts/find-node.sh and that fixes the iOS build. If this works for you, try using patch-package to make this change sticky.

I had the same issue on my build server but not my dev machine and adding unset npm_config_prefix with patch-package solves it.

This must be a joke, because I used a space in the parent folder name and it got fixed when I remove

…/React Native/project -> …/ReactNative/project

Worked for me 👯

Using RN 0.67.2 here and what finally worked for me was updating nvm from 0.33 to 0.39.1. The above mentioned fix (https://github.com/facebook/react-native/commit/35bcf934b186e581d100d43e563044300759557f) did not help, it actually caused the breakage. I think the fix assumes everyone is running the latest nvm.

After upgrading from node v12.19.0 (not working) to v14.16.1 with these commands:

nvm install lts/* --reinstall-packages-from=node --latest-npm
ln -s $(which node) /usr/local/bin/node
nvm unalias default

It’s works !

2nd command is important to set node in path for non interactive shell (XCode Script Phase are run in non interactive shell, so nvm/node settings from .bash_profile is not used !). For people not using nvm, make sure /usr/local/bin/node is pointing on your node install. Verify with /usr/local/bin/node --version

nvm unalias default should fix “PREFIX” error with nvm (maybe clean previous node version links)

any update on this? it blocks any fastlane/bitrise build

it works after upgrade my nvm version with brew upgrade nvm

Still having this issue with React 71.5. It builds locally but I can’t get it run in the CI. Have tried all of the above! Driving me crazy. Anyone else still struggling with this or has another solution?

Thanks!

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

It’s really working for me, Thank you so much !!! 😊

Interesting. Had same issue after upgrading from 0.66 to 0.67. Tried everything, deleting & re-installing pods, re-installing node modules, alias etc. The only think to have worked in my case was changing -e to +e in node_modules/react-native/scripts/find-node.sh

This fixed it for me when upgrading from .63 to .67, I think it might just be an issue to upgrading .67 in general

rm -rf ~/Library/Developer/Xcode/DerivedData + ctrl+k in xcode helped

Try running nvm unalias default

My System:

  • Apple Mac Mini M1 Silicon.
  • Mac OS 11.4
  • XCode 12.5 (open with Rosetta)
  • “react”: “17.0.1”
  • “react-native”: “0.64.2”,
  • Target Build IOS 14.3

I did the following:

  • Updated Node to 16.3.0 in NVM.
  • Uninstalled the React Native CLI and Reinstalled
  • nvm unalias default
  • Deleted node_modules folders, pod folder and cleaned build in Xcode
  • Deleted everything in /Users/xxxxx/Library/Developer/Xcode/DerivedData
  • Installed all packages (npm install)
  • Updated pod repo: arch -x86_64 pod repo update
  • Installed pod packages: arch -x86_64 pod install
  • Then build successfully

(Note: arch -x86_64 only for M1 Silicon)

This saves my day. Thanks.

nvm unalias default

this works for me

Environment

System: OS: macOS 11.2.3 CPU: (8) x64 Intel® Core™ i7-4770HQ CPU @ 2.20GHz Memory: 1.27 GB / 16.00 GB Shell: 5.8 - /usr/local/bin/zsh Binaries: Node: 12.18.0 - ~/.nvm/versions/node/v12.18.0/bin/node Yarn: 1.22.10 - ~/.nvm/versions/node/v12.18.0/bin/yarn npm: 6.14.5 - ~/.nvm/versions/node/v12.18.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: API Levels: 28, 29 Build Tools: 19.1.0, 20.0.0, 21.1.2, 22.0.1, 23.0.1, 23.0.2, 23.0.3, 24.0.0, 24.0.1, 24.0.2, 24.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.2, 27.0.3, 28.0.0, 28.0.1, 28.0.2, 28.0.3, 29.0.2, 30.0.3 System Images: android-28 | Google APIs Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.7042882 Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: 1.8.0_281 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.1 => 17.0.1 react-native: 0.64.0 => 0.64.0 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Things I’ve done to figure out my issue

I used react-native cli to upgrade and the following page to manually changes. https://react-native-community.github.io/upgrade-helper/?from=0.63.4&to=0.64.0

Upgrading version

0.64.0

Description

I’ve faced the following error when I want to start the IOS app with the “react-native run-ios” command. If I start the debug build from XCode, it is started successfully.

/bin/sh -c /Users/keklikc/Library/Developer/Xcode/DerivedData/DataroidMobile-gmjqxfphavicwkcccsennxqbhvuj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-0565B84ED1A643A94B66851B97B33BAC.sh nvm is not compatible with the “npm_config_prefix” environment variable: currently set to “/Users/keklikc/.nvm/versions/node/v12.18.0” Run unset npm_config_prefix to unset it. /Users/keklikc/.zshrc: line 83: zstyle: command not found /Users/keklikc/.zshrc: line 84: zstyle: command not found /Users/keklikc/.zshrc: line 85: zstyle: command not found /Users/keklikc/.oh-my-zsh/tools/check_for_upgrade.sh: line 32: syntax error near unexpected token )' /Users/keklikc/.oh-my-zsh/tools/check_for_upgrade.sh: line 32: () {’ /Users/keklikc/.oh-my-zsh/oh-my-zsh.sh: line 21: autoload: command not found /Users/keklikc/.oh-my-zsh/oh-my-zsh.sh: line 39: syntax error near unexpected token (' /Users/keklikc/.oh-my-zsh/oh-my-zsh.sh: line 39: for plugin ($plugins); do’ /Users/keklikc/.zshrc: line 120: autoload: command not found /Users/keklikc/.zshrc: line 129: add-zsh-hook: command not found nvm is not compatible with the “npm_config_prefix” environment variable: currently set to “/Users/keklikc/.nvm/versions/node/v12.18.0” Run unset npm_config_prefix to unset it. Command PhaseScriptExecution failed with a nonzero exit code

warning: 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. (in target ‘Flipper-Glog’ from project ‘Pods’) warning: 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. (in target ‘boost-for-react-native’ from project ‘Pods’) warning: The iOS Simulator deployment target ‘IPHONEOS_DEPLOYMENT_TARGET’ is set to 8.4, but the range of supported deployment target versions is 9.0 to 14.4.99. (in target ‘Flipper-PeerTalk’ from project ‘Pods’) warning: 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. (in target ‘YogaKit’ from project ‘Pods’) warning: no rule to process file ‘/Users/keklikc/Projects/Dataroid-MobileApp/ios/Pods/Flipper-RSocket/rsocket/README.md’ of type ‘net.daringfireball.markdown’ for architecture ‘x86_64’ (in target ‘Flipper-RSocket’ from project ‘Pods’) warning: no rule to process file ‘/Users/keklikc/Projects/Dataroid-MobileApp/ios/Pods/Flipper-RSocket/rsocket/benchmarks/CMakeLists.txt’ of type ‘text’ for architecture ‘x86_64’ (in target ‘Flipper-RSocket’ from project ‘Pods’) warning: no rule to process file ‘/Users/keklikc/Projects/Dataroid-MobileApp/ios/Pods/Flipper-RSocket/rsocket/benchmarks/README.md’ of type ‘net.daringfireball.markdown’ for architecture ‘x86_64’ (in target ‘Flipper-RSocket’ from project ‘Pods’) warning: 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. (in target ‘Flipper-DoubleConversion’ from project ‘Pods’)

** BUILD FAILED **

The following build commands failed: PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/keklikc/Library/Developer/Xcode/DerivedData/DataroidMobile-gmjqxfphavicwkcccsennxqbhvuj/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-0565B84ED1A643A94B66851B97B33BAC.sh (1 failure)

Reproducible demo

Upgrade from 0.63.4 to 0.64.0 then execute react-native run-ios

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

Hey all,

I got this issue as well, but before trying the monkey patch fix, I investigated my node and npm environment. Turns out I had a goofy environment (I think from installing node at one point with Homebrew, then from an installer, etc). I fixed my environment issues and this exact error disappeared. So, my advice is ensure your node environment is clean, your PATH is clean, etc.

After trying the way to comment all lines inside find-node.sh, it seems just works for one project. So, I follow your idea. I clean the whole npm, node, nvm and then reinstall them. It works. I think the problem is coming from unclear npm nvm node installations too. If someone is looking for a solution of errors, highly recommend to try it. Don’t trust brew install if you are using OSX.

In my case it was an old version of node 7.5.0 being cashed in ~/.nvm and find-node.sh was pulling this old node version instead of new one from n.

Here’s respective PR that’s not merged yet https://github.com/facebook/react-native/pull/30906

So just deleting old version fixed it.

Hey all,

I got this issue as well, but before trying the monkey patch fix, I investigated my node and npm environment. Turns out I had a goofy environment (I think from installing node at one point with Homebrew, then from an installer, etc). I fixed my environment issues and this exact error disappeared. So, my advice is ensure your node environment is clean, your PATH is clean, etc.

I had the same issue, apparently, there was an update to xcode while the simulator is running so it was not updated to the latest iOS, while xcode was trying to build the project with latest params for latest simulator who was not updated. I forced close the simulator and re-run, everything worked fine.

I’ve made a brand new project, running on react-native version 0.70.4 and I’m getting the RBReactNativeSpec error when trying to build to a device.

I’m currently facing this issue mac os 12.5 xcode 13

I have a solution that works but is not permanent if you redo pod install 😔

In Xcode select Pods >>>FBReactNativeSpec >>> Build phases >>> Just move the CP-USER scripts before the Headers script.

When are you going to fix this?

This didn’t fix, but deleting CP-USER phase did. I took this workaround from here

Intel 2018 Mac, node 16 installed standalone (no nvm)

npx react-native init RNFBNativeSpecSTILLBorked --template react-native-template-typescript worked

XCode build and run within XCode works

npm run ios failed with FBReactNativeSpec errors like the ones above…

edited find-node.sh to include the unset statements and npm run ios works.

Rearranging the build phase steps didn’t work for me. Literally a fresh install broken, for 3 releases now (I installed .66).

EDIT: I stated “no nvm installed” - however after closer inspection I discovered the path that is checked for an nvm installation actually exists, but my local which nvm command returned nothing. I forgot I installed it previously and it looks like the uninstall or some other process did not cleanly remove this hidden directory.

So I removed the hidden directory (rm -rf ~/.nvm), removed the edits I made to find-node.sh, and re-ran npm run ios and the build worked.

Double check that you have the directory present. It may be there after all!

I added unset PREFIX (probably unset npm_config_prefix for OP) to the top of node_modules/react-native/scripts/find-node.sh and that fixes the iOS build. If this works for you, try using patch-package to make this change sticky.

This worked for me on my Mac M1, but then it starting showing the same error again. I am currently using React-Native 0.66 alpha release 2. I had to change this line:

set -e

to this:

set +e

After tried all solutions referred here, removing the ios/Pods directory and pod install again resolved my issue

this resolved all of my issues:

nvm unalias default

This solution worked for me. Thank you.

@ceyhunkeklik I do not think you were affected by the “space in the path” issue that seems to be related to FBReactNativeSpec though…

If using yarn and nvm, try

  1. Run yarn config get prefix
  2. If it returned something other than undefined, make note of it and then run yarn config delete prefix
  3. Run the ios build again

That was the only thing that worked for me (aside from editing node_modules/react-native/scripts/find-node.sh). This was hard to find, since the build failed with

** BUILD FAILED **

The following build commands failed:
	PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/lauriharpf/Library/Developer/Xcode/DerivedData/project-fktbpbsywsmjgbcuemnwiknkxipt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-B3138396E7E04B5E9069945E15936FC6.sh
(1 failure)

and only way above in the build output (>100 unrelated rows) was the following telltale message. So also try searching the build output for e.g. nvm is not compatible with to identify what is causing the failure in your system.

nvm is not compatible with the "npm_config_prefix" environment variable: currently set to "/Users/lauriharpf/.yarn"
Run `unset npm_config_prefix` to unset it.

In case anyone wants to try a temporary fix that worked for me: I ended up commenting all lines inside node_modules/react-native/scripts/find-node.sh. It seems as if my node environment didn’t agree with this script. I could build and run my project on an actual device afterwards without any further issues.

Holly…after two weeks researching, it works … it works. OMG. Thanks for million. Dude I’m about cryin.

just wanna say massive shoutout to @giuseppealbrizio and their solution!!! Thanks a million!

This issue was happening for us on our local Github Actions Mac agent. Even though we are using https://github.com/actions/setup-node to specify a Node Version (12.16.3), React Native is ignoring that version of Node and instead using whatever NVM is currently set to. I think that’s because of this script which gets run by generate-specs.sh during an iOS build phase.

So we had NVM installed on this machine and Node was set to Node 15. We downgraded it to Node 12 and the build passed. This isn’t ideal though because our Github Actions workflow is using one Node version via https://github.com/actions/setup-node to do yarn install, but then potentially a completely different Node version during the iOS build phases if our build agent happens to have NVM installed.

I’m not sure React Native should even be meddling with the path to node? I’m thinking the find-node.sh script should be first checking if node is on the current path before assuming you wanna use something else like NVM, or at least have a way to disable that find-node check. Otherwise it can affect CI servers without even realising it.

as turned out the problem was a space in the project path. Interesting that previous version wasn’t be under this issue

Got the same thing trying to upgrade from 0.64.0-rc.3 to stable 0.64.0.

  • I cleared xcode build
  • watchman watch-del-all
  • yarn start --reset-cache
  • removed Pods & Podsfile.lock
  • removed node_modules
  • changed xcode build system to Legacy and back
  • rebooted laptop

Nothing helps.

Xcode 12.4 Big Sur Intel Node 15

could you solve it?

I have tried (unset npm_config_prefix) workaround but I am still getting this error and iOS build failed.

Trying to solve this issue with no luck.

I had the same issue FBReactNativeSpec failing on making the build. My specific case was that neither an init AwesomeProject to run a helloworld was lifting the ios project. Solved this checking the path with pwd command /Users/myuser/React Native/AwesomeProject my path included a folder with a space “React Native” just had to delete that space to set the path as follows: /Users/myuser/ReactNative/AwesomeProject then do all the stuff to lift ios in your RN project run

rm -rf node_modules yarn.lock package-lock.json ios/Podfile.lock ios/Pods && 
yarn && cd ios && pod install && cd ..

then open your Awesome.xcodeproj located on ios folder with Xcode run Product > Clean build folder then Product > build

I deleted node_modules and re-ran yarn install then pod install in .\ios

For me it failed because I’m not using nvm anymore but there was still a ~/.nvm directory in my home folder which the find-node.sh script was targeting. Removing the directory fixed the problem.

I have a solution that works but is not permanent if you redo pod install 😔

In Xcode select Pods >>>FBReactNativeSpec >>> Build phases >>> Just move the CP-USER scripts before the Headers script.

When are you going to fix this? Worked for me

I have a solution that works but is not permanent if you redo pod install 😔

In Xcode select Pods >>>FBReactNativeSpec >>> Build phases >>> Just move the CP-USER scripts before the Headers script.

When are you going to fix this?

Thank you! This saved me

I managed to fix this issue by installing the latest react-native-codegen version:

yarn add --dev react-native-codegen

or:

npm install --save-dev react-native-codegen

oh right, maybe. i have System Integrity Protection disabled

This happens to me if I try to install pods by typing pod install. I’m able to get the app to run without error if I use npx pod-install instead.

@devmindset-shaunvos Thank you! Running “nvm unalias default” worked for me!

I was able to resolve this problem with node by the following commands:

  1. brew uninstall yarn
  2. npm install --global yarn

This also worked for me. But first I uninstalled nvm and node entirely and reinstalled them with homebrew.

I managed to solve the issue by re-installing NVM and downgrading Node to 12.5 and it worked for me after a day of headaches…

This fixed it for me:

  1. Reinstall node & nvm like explained here: https://jamesauble.medium.com/install-nvm-on-mac-with-brew-adb921fb92cc

  2. Install older Node version (12.5 in my case) && use it

nvm install 12.5
nvm use 12.5
  1. Install pods & build

  2. 🚀

In my case the solution was to switch from bash to zsh terminal

@ha-family thanks, it works for me

I had to upgrade with

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

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

  • I removed space in the folder path-name
  • Commented use_flipper!() in podfile
  • Then cd to iOS directory and pod install

It resolved my issue

Was upgrading from 0.61.4 to 0.64.0 and ran into a separate issue with FBReactNativeSpec. In case this helps other Googlers (as this is the first search result to show up):

Updating Podfile based on the guide below helped resolve the issue: https://react-native-community.github.io/upgrade-helper/?from=0.61.4&to=0.64.0

Mainly adding the lines below, and removing the individual podspecs:

config = use_native_modules!
use_react_native!(
    :path => config[:reactNativePath],
    # to enable hermes on iOS, change `false` to `true` and then install pods
    :hermes_enabled => false
  )

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

Thank you so much @giuseppealbrizio after spending many days with this error I lost all hope and then your comment rescued me. Thanks a lot.

Thanks for pointing this out @giuseppealbrizio it fixed my issue

What’s more strange is that it works exactly the opposite in android. When react-native run-android, it works well but when built from android studio it can’t find the js bundler (the build is ok).