Tag Archives: React Native Project Run Error

React Native Project Run Error [How to Solve]

React native version: 0.67

Initialize and run the project according to the official document

$ npx react-native init AwesomeProject
$ yarn ios

The error message is as follows

The following build commands failed: 
	PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/zh/Library/Developer/Xcode/DerivedData/AwesomeProject-cvxgkvyxvvajjvaydcivldmzlgxr/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-5F4C70EF7D90A5A5BDAEB404279F232A.sh (in target 'FBReactNativeSpec' from project 'Pods') (1 failure)

Possible causes

  1. The project path contains white space characters
  2. NVM is used for node installation

I’m because of reason 2. The solution is to go to node_modules/react-native/scripts/find-node. SH, comment out this part of the file

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

Then execute yarn IOS , and the execution will be successful