react-native-community / upgrade-support

A central community-backed place to request and give help when upgrading your app.
MIT License
254 stars 2 forks source link

FBReactNativeSpec error after upgrade from 0.63.4 to 0.64.0 #138

Closed ceyhunkeklik closed 2 years ago

ceyhunkeklik commented 3 years ago

Environment

System: OS: macOS 11.2.3 CPU: (8) x64 Intel(R) Core(TM) 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

german970814 commented 3 years ago

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

Hi @giuseppealbrizio, Thanks for your solution.

I'm trying to follow your solution step by step, but I'm stuck with step 1 and 5. Could you please advise me? (I'm still very beginner in react-native)

What I've done?

  1. skip npm uninstall -g react-native-cli because I didn't have permission to access it. Should I run it with sudo?
  2. Remove the space in the folder from IT Project => IT_Projects & Moved project to the IT_Projects folder
  3. I've checked the react-native version. It's already updated to the latest version (0.64). So I skip it
  4. I removed node_modules, podfile.lock and Pods folder. I can't see any yarn.lock file in the root folder.

5.run yarn install && npx pod-install & run again yarn install on the root, but it's saying 'command not found:yarn.' When I run npx pod-installby itself, it's giving me an error (Invalid 'podfile'file: cannot load such file. => (Found a way) I was in the old folder (IT Project). That's why it's saying can't load a file. I corrected my path to _ITProjects folder. And, run npm install instead & npx pod-install => It's successfully installed.

  1. run npx react-native run-ios but failed again with another following error.
** BUILD FAILED **
The following build commands failed:
  CompileC /Users/youber/Library/Developer/Xcode/DerivedData/'projectName'-bztvtglsaqsuqjbqyfrvbjraamwc/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RNGestureHandler.build/Objects-normal/x86_64/RNGestureHandlerManager.o /Users/destroyyouber/IT_Projects/HappyTooCustomerApp1.0_FrontEnd/node_modules/react-native-gesture-handler/ios/RNGestureHandlerManager.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

Did you solve it?

duanyrf commented 3 years ago

this resolved all of my issues:

nvm unalias default

@jeancatarina Your answer is the best/clear/right/elegant of all the answers I read here. It fixed the errors and now the app has been successfully built. Congratulations!

sreekanthbathinis commented 3 years ago

Remove node modules, podfile.lock, pods folder and workspace, then remove all default pods like pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"

and add require_relative '../node_modules/react-native/scripts/react_native_pods' in podfile

and then do npm/ yarn install , pod install I did the same it is working for me

IFMaggie commented 3 years ago

this resolved all of my issues:

nvm unalias default

I solved my problem in this way, thank you

angelguillen10 commented 3 years ago

Environment

System: OS: macOS 11.2.3 CPU: (8) x64 Intel(R) Core(TM) 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

bustazone commented 3 years ago

it works after upgrade my nvm version with brew upgrade nvm

Yeah!!! This works for me too!!!

dotansimha commented 3 years ago

Is there a solution for projects that doesn't even use nvm? I don't have it installed, and my NodeJS version is set manually or by using fnm (https://github.com/Schniz/fnm). Seems a bit weird that RN requires an external tool instead of just using node from that shell that initiated it?

Aure77 commented 3 years ago

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)

moyolvera commented 3 years ago

this resolved all of my issues:

nvm unalias default

this also worked for me!

ozanmanav commented 3 years ago

I downgraded from 14.16.1 to 14.15.3 and it worked. I'm not sure why.

k0nserv commented 3 years ago

If anyone is encountering issues with the error Cannot find module 'react-native-codegen/package.json' during the build phase after fixing the above issues and the cycle problem I've explained the problem and potential solutions in https://github.com/react-native-community/upgrade-support/issues/157

lauriharpf commented 3 years ago

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.
Pandazaur commented 3 years ago

I managed to make it works using this flow (I'm using node v14.16.1):

  1. Updated nvm to 0.38.0
  2. source $HOME/.zshrc to ensure that last version of nvm is installed (nvm --version)
  3. cd ios && xcodebuild clean && cd ..
  4. I tried to run npm run ios and faced this issue: https://github.com/facebook/react-native/issues/31180 so I had to install npm i react-native-codegen@0.0.7 --save-dev
leethree commented 3 years ago

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
habovh commented 3 years ago

There is definitely something up with the space in the file path... See my comment here as I mix up issues, it seems 0.64 is regressing somewhere regarding file path interpretation...

ceyhunkeklik commented 3 years ago

This issue fixed for me after upgrade from 0.63.4 to.0.64.1.

habovh commented 3 years ago

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

elkinjosetm commented 3 years ago

I've tried multiple things, creating the find-node.sh file did work, but I didn't want to modify node_modules folder, so I kept researching. The issue is clear that is related with the nodeJS update I had to do. Using npm run ios worked but yarn ios didn't, so I uninstall yarn completely from my machine, and installed it again with npm, and everything is working as expected.

I'm using: node -> v14.16.1 npm -> v6.14.12 yarn -> v1.22.10 (installed from npm) react-native -> v0.64.1 xcode -> v12.5

harshakumar87 commented 3 years ago

Hi, Can anyone tell me the detailed steps to resolve the issue?

Below is my environment detail. XCode - v12.5 Node - v14.16.1 RN Version - v0.64.1

I have tried the below solution, still not working 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.

Thanks in advance

dmusev commented 3 years ago

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. 🚀

jaysu77 commented 3 years ago

Hi All ,After doing pod install getting this error,Can anyone please help. Downloading dependencies Installing AppAuth (1.4.0) Installing BVLinearGradient (2.5.6) Installing CocoaAsyncSocket (7.6.5) Installing DoubleConversion (1.1.6) Installing FBLazyVector (0.64.1) Installing FBReactNativeSpec (0.64.1) [!] /bin/bash -c set -e mkdir -p /Volumes/MacHD - Data/frontend/node_modules/react-native/scripts/../React/FBReactNativeSpec/FBReactNativeSpec && touch /Volumes/MacHD - Data/frontend/node_modules/react-native/scripts/../React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h /Volumes/MacHD - Data/frontend/node_modules/react-native/scripts/../React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec-generated.mm

touch: /Volumes/MacHD: Read-only file system touch: /Volumes/MacHD: Read-only file system

noway commented 3 years ago

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
  2. 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
  3. 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)
ajayesivan commented 3 years ago
brew uninstall yarn   
npm install --global yarn

This worked for me.

albertoammar commented 3 years ago

Consegui resolver esse problema com o nó pelos seguintes comandos:

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

Thanks, it work for me!!! I didn't understand the down vote.

uloco commented 3 years ago

The issue for me was, that I had both fnm and nvm installed. The find-node.sh script in react-native loads nvm if present. Additionally loading fnm in your own .zshrc results in node loaded twice and somehow this causes the prefix problem.

harterc1 commented 3 years ago

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.

NathanNovak commented 3 years ago

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

shabeer3508 commented 3 years ago

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

roy-law commented 3 years ago

nvm unalias default

this works for me

MJahanzaibKhan commented 3 years ago

anyone help me for this issue

MJahanzaibKhan commented 3 years ago
Screenshot 2021-06-10 at 4 19 04 AM Screenshot 2021-06-10 at 5 15 48 AM
sa-whyayala commented 3 years ago

I am also having this issue on a vanilla brand new project. No spaces in my pathing.

Node 14.17 (installed via nvm) Yarn 1.22.10 (installed via yvm) RN 0.64.2 (followed setup steps from https://reactnative.dev/docs/environment-setup)

Have to say, little disappointing this didn't work out of the box. I was trying to start a new project to migrate some components over from an existing one where I was also having trouble upgrading.

ShaunGVos commented 3 years ago

Try running nvm unalias default

My System:

(Note: arch -x86_64 only for M1 Silicon)

doug1n commented 3 years ago

@devmindset-shaunvos I love you, thanks!!!

flavioribeirojr commented 3 years ago

@devmindset-shaunvos Thank you for your tip! Saved my life :)

McPatto commented 3 years ago

Tried what @devmindset-shaunvos said but I have same error: Command PhaseScriptExecution failed with a nonzero exit code This fails when this error occurs before: /Xcode/DerivedData/xxxxxx/Build/Intermediates.noindex/xxxx.build/Debug-iphonesimulator/xxxx.build/Script-xxxxxxxx.sh: line 9: : No such file or directory

salomegoosen123 commented 3 years ago

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

McPatto commented 3 years ago

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

focux commented 3 years ago

this resolved all of my issues:

nvm unalias default

This solution worked for me. Thank you.

Maxeeezy commented 3 years ago

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

iLevye commented 3 years ago

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

uloco commented 3 years ago

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.

annieneedscoffee commented 3 years ago

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.

johnny-minty commented 3 years ago

As per other comments this issue seems to manifest when you have multiple install paths for node i.e. via brew and nvm.

Make a choice on your avenue to install node and remove the other. If you're using NVM make sure you set the default node to the required version then run:

"nvm unalias default"

noway commented 3 years ago

For Apple Silicon macs, if you installed node from brew:

ln -s /opt/homebrew/bin/node /usr/bin/node
aurimassteponaitis commented 3 years ago

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!

joeyfigaro commented 3 years ago

For Apple Silicon macs, if you installed node from brew:

ln -s /opt/homebrew/bin/node /usr/bin/node

Is that supposed to be /usr/local/bin/node? Mac OS is unhappy about operating on /usr/bin

noway commented 3 years ago

oh right, maybe. i have System Integrity Protection disabled

muhammadhassan149 commented 3 years ago

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

After removing space, it works man

alon-ha commented 3 years ago

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.shscript 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",
    }
  2. Create postinstall.js file.

  3. 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!