facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.24k stars 24.34k forks source link

New project not working on IOS Xcode 12.4 react-native 0.64 (Command PhaseScriptExecution failed with a nonzero exit code) #31181

Closed javierdac closed 3 years ago

javierdac commented 3 years ago

Please provide all the information requested. Issues that do not follow this format are likely to stall.

Description

i try to create a new project (npx react-native init TestApp --version 0.64.0 --template react-native-template-typescript). It fails with XCode 12.4

React Native version:

System: OS: macOS 10.15.7 CPU: (8) x64 Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz Memory: 78.82 MB / 16.00 GB Shell: 3.1.2 - /usr/local/bin/fish Binaries: Node: 14.13.1 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 6.14.8 - /usr/local/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: 23, 28, 29 Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3 System Images: android-30 | Google APIs Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.6953283 Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: 1.8.0_265 - /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

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. npx react-native init TestProject
  2. npm i && cd ios && pod install && cd.. && npm run ios

Expected Results

Run the base app

Snack, code example, screenshot, or link to a repository:

Captura de Pantalla 2021-03-17 a la(s) 17 58 34

Error: Command PhaseScriptExecution failed with a nonzero exit code

AutoFt commented 3 years ago

I have the same problem.

This is my configuration information.

System: OS: macOS 11.2.3 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 3.76 GB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.15.4 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 6.14.10 - /usr/local/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: Not Found IDEs: Android Studio: Not Found 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

mohdabbas commented 3 years ago

Same issue for me as well!!! Any solutions?? I tried https://dev.to/glocore/react-native-command-phasescriptexecution-failed-of9, but no success!

rochapablo commented 3 years ago

I'm also having trouble to start a new RN project. I've already tried to add a dummy.swift and do the Bridging Header Thing, but still not working.

ld: warning: Could not find or use auto-linked library 'swiftFoundation'
ld: warning: Could not find or use auto-linked library 'swiftDarwin'
ld: warning: Could not find or use auto-linked library 'swiftUIKit'
ld: warning: Could not find or use auto-linked library 'swiftCoreFoundation'
ld: warning: Could not find or use auto-linked library 'swiftQuartzCore'
ld: warning: Could not find or use auto-linked library 'swiftCore'
ld: warning: Could not find or use auto-linked library 'swiftCoreGraphics'
ld: warning: Could not find or use auto-linked library 'swiftObjectiveC'
ld: warning: Could not find or use auto-linked library 'swiftDispatch'
ld: warning: Could not find or use auto-linked library 'swiftSwiftOnoneSupport'
ld: warning: Could not find or use auto-linked library 'swiftCoreImage'
ld: warning: Could not find or use auto-linked library 'swiftMetal'
Undefined symbols for architecture arm64:
  "protocol descriptor for Swift.ExpressibleByFloatLiteral", referenced from:
      l_got.$ss25ExpressibleByFloatLiteralMp in libYogaKit.a(YGLayoutExtensions.o)
  "associated type descriptor for Swift.ExpressibleByIntegerLiteral.IntegerLiteralType", referenced from:
      l_got.$s18IntegerLiteralTypes013ExpressibleByaB0PTl in libYogaKit.a(YGLayoutExtensions.o)
  "associated conformance descriptor for Swift.ExpressibleByIntegerLiteral.Swift.ExpressibleByIntegerLiteral.IntegerLiteralType: Swift._ExpressibleByBuiltinIntegerLiteral", referenced from:
      l_got.$ss27ExpressibleByIntegerLiteralP0cD4TypeAB_s01_ab7BuiltincD0Tn in libYogaKit.a(YGLayoutExtensions.o)
  "method descriptor for Swift.ExpressibleByFloatLiteral.init(floatLiteral: A.FloatLiteralType) -> A", referenced from:
      l_got.$ss25ExpressibleByFloatLiteralP05floatD0x0cD4TypeQz_tcfCTq in libYogaKit.a(YGLayoutExtensions.o)
  "protocol descriptor for Swift.ExpressibleByIntegerLiteral", referenced from:
      l_got.$ss27ExpressibleByIntegerLiteralMp in libYogaKit.a(YGLayoutExtensions.o)
  "value witness table for Builtin.Int32", referenced from:
      full type metadata for __C.YGUnit in libYogaKit.a(YGLayoutExtensions.o)
  "__swift_FORCE_LOAD_$_swiftCoreImage", referenced from:
      __swift_FORCE_LOAD_$_swiftCoreImage_$_YogaKit in libYogaKit.a(YGLayoutExtensions.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftCoreImage_$_YogaKit)
  "protocol witness table for Swift.Float : Swift._ExpressibleByBuiltinFloatLiteral in Swift", referenced from:
      associated type witness table accessor for Swift.ExpressibleByFloatLiteral.FloatLiteralType : Swift._ExpressibleByBuiltinFloatLiteral in __C.YGValue : Swift.ExpressibleByFloatLiteral in YogaKit in libYogaKit.a(YGLayoutExtensions.o)
  "__swift_FORCE_LOAD_$_swiftFoundation", referenced from:
      __swift_FORCE_LOAD_$_swiftFoundation_$_rn64ts in dummy.o
      __swift_FORCE_LOAD_$_swiftFoundation_$_YogaKit in libYogaKit.a(YGLayoutExtensions.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftFoundation_$_rn64ts, __swift_FORCE_LOAD_$_swiftFoundation_$_YogaKit )
  "_swift_getForeignTypeMetadata", referenced from:
      type metadata accessor for __C.YGValue in libYogaKit.a(YGLayoutExtensions.o)
      type metadata accessor for __C.YGUnit in libYogaKit.a(YGLayoutExtensions.o)
  "__swift_FORCE_LOAD_$_swiftObjectiveC", referenced from:
      __swift_FORCE_LOAD_$_swiftObjectiveC_$_rn64ts in dummy.o
      __swift_FORCE_LOAD_$_swiftObjectiveC_$_YogaKit in libYogaKit.a(YGLayoutExtensions.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftObjectiveC_$_rn64ts, __swift_FORCE_LOAD_$_swiftObjectiveC_$_YogaKit )
  "protocol witness table for Swift.Int : Swift._ExpressibleByBuiltinIntegerLiteral in Swift", referenced from:
      associated type witness table accessor for Swift.ExpressibleByIntegerLiteral.IntegerLiteralType : Swift._ExpressibleByBuiltinIntegerLiteral in __C.YGValue : Swift.ExpressibleByIntegerLiteral in YogaKit in libYogaKit.a(YGLayoutExtensions.o)
  "method descriptor for Swift.ExpressibleByIntegerLiteral.init(integerLiteral: A.IntegerLiteralType) -> A", referenced from:
      l_got.$ss27ExpressibleByIntegerLiteralP07integerD0x0cD4TypeQz_tcfCTq in libYogaKit.a(YGLayoutExtensions.o)
  "__swift_FORCE_LOAD_$_swiftCoreFoundation", referenced from:
      __swift_FORCE_LOAD_$_swiftCoreFoundation_$_rn64ts in dummy.o
      __swift_FORCE_LOAD_$_swiftCoreFoundation_$_YogaKit in libYogaKit.a(YGLayoutExtensions.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftCoreFoundation_$_YogaKit, __swift_FORCE_LOAD_$_swiftCoreFoundation_$_rn64ts )
  "associated type descriptor for Swift.ExpressibleByFloatLiteral.FloatLiteralType", referenced from:
      l_got.$s16FloatLiteralTypes013ExpressibleByaB0PTl in libYogaKit.a(YGLayoutExtensions.o)
  "__swift_FORCE_LOAD_$_swiftQuartzCore", referenced from:
      __swift_FORCE_LOAD_$_swiftQuartzCore_$_YogaKit in libYogaKit.a(YGLayoutExtensions.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftQuartzCore_$_YogaKit)
  "__swift_FORCE_LOAD_$_swiftDispatch", referenced from:
      __swift_FORCE_LOAD_$_swiftDispatch_$_rn64ts in dummy.o
      __swift_FORCE_LOAD_$_swiftDispatch_$_YogaKit in libYogaKit.a(YGLayoutExtensions.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftDispatch_$_YogaKit, __swift_FORCE_LOAD_$_swiftDispatch_$_rn64ts )
  "associated conformance descriptor for Swift.ExpressibleByFloatLiteral.Swift.ExpressibleByFloatLiteral.FloatLiteralType: Swift._ExpressibleByBuiltinFloatLiteral", referenced from:
      l_got.$ss25ExpressibleByFloatLiteralP0cD4TypeAB_s01_ab7BuiltincD0Tn in libYogaKit.a(YGLayoutExtensions.o)
  "__swift_FORCE_LOAD_$_swiftUIKit", referenced from:
      __swift_FORCE_LOAD_$_swiftUIKit_$_YogaKit in libYogaKit.a(YGLayoutExtensions.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftUIKit_$_YogaKit)
  "__swift_FORCE_LOAD_$_swiftMetal", referenced from:
      __swift_FORCE_LOAD_$_swiftMetal_$_YogaKit in libYogaKit.a(YGLayoutExtensions.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftMetal_$_YogaKit)
  "Swift.Float.init(Swift.Double) -> Swift.Float", referenced from:
      static (extension in YogaKit):CoreGraphics.CGFloat.% postfix(CoreGraphics.CGFloat) -> __C.YGValue in libYogaKit.a(YGLayoutExtensions.o)
      (extension in YogaKit):__C.YGValue.init(CoreGraphics.CGFloat) -> __C.YGValue in libYogaKit.a(YGLayoutExtensions.o)
  "__swift_FORCE_LOAD_$_swiftDarwin", referenced from:
      __swift_FORCE_LOAD_$_swiftDarwin_$_rn64ts in dummy.o
      __swift_FORCE_LOAD_$_swiftDarwin_$_YogaKit in libYogaKit.a(YGLayoutExtensions.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftDarwin_$_YogaKit, __swift_FORCE_LOAD_$_swiftDarwin_$_rn64ts )
  "__swift_FORCE_LOAD_$_swiftCoreGraphics", referenced from:
      __swift_FORCE_LOAD_$_swiftCoreGraphics_$_rn64ts in dummy.o
      __swift_FORCE_LOAD_$_swiftCoreGraphics_$_YogaKit in libYogaKit.a(YGLayoutExtensions.o)
     (maybe you meant: __swift_FORCE_LOAD_$_swiftCoreGraphics_$_YogaKit, __swift_FORCE_LOAD_$_swiftCoreGraphics_$_rn64ts )
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

image

"react": "17.0.1",
"react-native": "0.64.0"
node v14.16.0
npm 6.14.11
Xcode 12.4
macOS Big Sur - Chip Apple M1
ahtishamali09 commented 3 years ago

Same Error i tried to create new project and facing this issue

Screenshot 2021-03-18 at 3 37 05 PM
Yonom commented 3 years ago

In my case, the PhaseScriptExecution script was failing for this reason:

nvm is not compatible with the "PREFIX" environment variable: currently set to "/usr/local"

There seems to be a clash in the environment variables used by react native and nvm?

I solved the issue by uninstalling nvm

Also, make sure you don't have any spaces in the project path

giuseppealbrizio commented 3 years ago

This happened also to me upgrading from 0.63 to 0.64. After trying all solutions with no luck, I found that moving the folder to a directory where the path contain no spaces works and build the app successfully.

https://github.com/facebook/react-native/issues/31206

hudsonfoo commented 3 years ago

Per this article I used: nvm unalias default and my app is now running. Yay

XTKKKKK commented 3 years ago

It happened to me as well. You can check the error shell, try to run it via bash directly to check the shell problem. In my case, I found my bash_profile is accidentally edited by anaconda, after delete it, the project could run again

girish54321 commented 3 years ago

Hi all any update i want to try react-native 0.64 but it never builds for iOS any help.

marcoisgood commented 3 years ago

same here. cannot solve the issue and it shows command /bin/sh failed with exit code 11. any idea?

ferdicus commented 3 years ago

In my case, the PhaseScriptExecution script was failing for this reason:

nvm is not compatible with the "PREFIX" environment variable: currently set to "/usr/local"

There seems to be a clash in the environment variables used by react native and nvm?

I solved the issue by uninstalling nvm

Also, make sure you don't have any spaces in the project path

I guess that's a solution 😄

Any workarounds without nuking nvm would be more than welcome though

IMaz6 commented 3 years ago

Same issue here. Upgrading flipper doesn't change anything - also looking for a solution without uninstalling nvm.

ferdicus commented 3 years ago

Per this article I used: nvm unalias default and my app is now running. Yay

This only throws an Alias default doesn't exist! error for me 😞

Additionally the linked article explains how to install nvm via homebrew, which is something that nvm maintainers are explicitly recommending against, as it's not supported by them, just FYI

ferdicus commented 3 years ago

Interesting tidbit, when building via XCode it does not complain, compiles and installs on the simulator. I only encounter this issue when trying to build via command line react-native run-ios 🤔

ferdicus commented 3 years ago

Ok, this comment on another ticket resolved the issue for me:

I'm using NVM and had the same issue for now I changed the file node_modules/react-native/scripts/find-node.sh adding before set -e:

unset npm_config_prefix
unset PREFIX
IMaz6 commented 3 years ago

Ok, this comment on another ticket resolved the issue for me:

I'm using NVM and had the same issue for now I changed the file node_modules/react-native/scripts/find-node.sh adding before set -e:

unset npm_config_prefix
unset PREFIX

Doesn't work for me. :/ Note I am running this in CircleCi pipeline.

Node: 12.18.4 xcode: 12.4 detox: 18

rdsedmundo commented 3 years ago

I have figured out a solution, if you're using nvm make sure you don't have another globally installed version of Node/npm.

If you aren't sure whether or not you have a global version, go to your bash_profile/zshrc and comment the three nvm initialization lines (export NVM_DIR="$HOME/.nvm" [...]), then open a new terminal and do node --version, if it still finds something it means that you have a global version somewhere, and you can find its path with which node.

In my case I'm using Homebrew, and I had a global version of Node that I wasn't even aware coming from the yarn formula, I discovered it after running brew uses --installed node. I went ahead and uninstalled yarn using brew uninstall --force yarn, which automatically uninstalled its node/npm dependency, then uncommented the nvm initialization lines, and then I reinstalled yarn using nvm's npm with npm i -g yarn, and now everything works.

As for a proper resolution on the react-native repo, I suspect that the problem is somehow coming from find-node.sh which is a new file on 0.64. Can't really confirm or propose a solution though. cc @hramos

serdargun commented 3 years ago

Here what worked for me. I was using node version 15.14.0 because homebrew automatically installed this version. I uninstalled node with brew uninstall node

After that I installed node from official website with exact version 14.16.1. When installation done I clean my project with Cmd + Shift + K and run.

Liqiankun commented 3 years ago

rm -rf ~/.nvm

This works for me!!!!

bujoralexandru commented 3 years ago

I have figured out a solution, if you're using nvm make sure you don't have another globally installed version of Node/npm.

If you aren't sure whether or not you have a global version, go to your bash_profile/zshrc and comment the three nvm initialization lines (export NVM_DIR="$HOME/.nvm" [...]), then open a new terminal and do node --version, if it still finds something it means that you have a global version somewhere, and you can find its path with which node.

In my case I'm using Homebrew, and I had a global version of Node that I wasn't even aware coming from the yarn formula, I discovered it after running brew uses --installed node. I went ahead and uninstalled yarn using brew uninstall --force yarn, which automatically uninstalled its node/npm dependency, then uncommented the nvm initialization lines, and then I reinstalled yarn using nvm's npm with npm i -g yarn, and now everything works.

As for a proper resolution on the react-native repo, I suspect that the problem is somehow coming from find-node.sh which is a new file on 0.64. Can't really confirm or propose a solution though. cc @hramos

After doing what @rdsedmundo suggested, I still didn't came by a fix so then I read the error logs a little closer and it suggested me to do:

To replace NODE_BINARY=node image with the actual result of the which node command, which in my case looks something like this: image

Also CMD-Shift-K to clean the build folder (just to make sure), then build again, and everything worked fine. This method might come in handy for those who still want to keep nvm.

This worked for me, hope it helps whomever stumbles across this problem.

nubo94 commented 3 years ago

Per this article I used: nvm unalias default and my app is now running. Yay

Work for me, thanks!

tvtruong3964 commented 3 years ago

I have figured out a solution, if you're using nvm make sure you don't have another globally installed version of Node/npm.

If you aren't sure whether or not you have a global version, go to your bash_profile/zshrc and comment the three nvm initialization lines (export NVM_DIR="$HOME/.nvm" [...]), then open a new terminal and do node --version, if it still finds something it means that you have a global version somewhere, and you can find its path with which node.

In my case I'm using Homebrew, and I had a global version of Node that I wasn't even aware coming from the yarn formula, I discovered it after running brew uses --installed node. I went ahead and uninstalled yarn using brew uninstall --force yarn, which automatically uninstalled its node/npm dependency, then uncommented the nvm initialization lines, and then I reinstalled yarn using nvm's npm with npm i -g yarn, and now everything works.

As for a proper resolution on the react-native repo, I suspect that the problem is somehow coming from find-node.sh which is a new file on 0.64. Can't really confirm or propose a solution though. cc @hramos

it's work for me.

Thank you

zees98 commented 3 years ago

I have figured out a solution, if you're using nvm make sure you don't have another globally installed version of Node/npm.

If you aren't sure whether or not you have a global version, go to your bash_profile/zshrc and comment the three nvm initialization lines (export NVM_DIR="$HOME/.nvm" [...]), then open a new terminal and do node --version, if it still finds something it means that you have a global version somewhere, and you can find its path with which node.

In my case I'm using Homebrew, and I had a global version of Node that I wasn't even aware coming from the yarn formula, I discovered it after running brew uses --installed node. I went ahead and uninstalled yarn using brew uninstall --force yarn, which automatically uninstalled its node/npm dependency, then uncommented the nvm initialization lines, and then I reinstalled yarn using nvm's npm with npm i -g yarn, and now everything works.

As for a proper resolution on the react-native repo, I suspect that the problem is somehow coming from find-node.sh which is a new file on 0.64. Can't really confirm or propose a solution though. cc @hramos

OMG! Thank you so much. I've been pulling my hair out over this for 2 days. You rock!

rlsbelmiro commented 3 years ago

I have figured out a solution, if you're using nvm make sure you don't have another globally installed version of Node/npm. If you aren't sure whether or not you have a global version, go to your bash_profile/zshrc and comment the three nvm initialization lines (export NVM_DIR="$HOME/.nvm" [...]), then open a new terminal and do node --version, if it still finds something it means that you have a global version somewhere, and you can find its path with which node. In my case I'm using Homebrew, and I had a global version of Node that I wasn't even aware coming from the yarn formula, I discovered it after running brew uses --installed node. I went ahead and uninstalled yarn using brew uninstall --force yarn, which automatically uninstalled its node/npm dependency, then uncommented the nvm initialization lines, and then I reinstalled yarn using nvm's npm with npm i -g yarn, and now everything works. As for a proper resolution on the react-native repo, I suspect that the problem is somehow coming from find-node.sh which is a new file on 0.64. Can't really confirm or propose a solution though. cc @hramos

After doing what @rdsedmundo suggested, I still didn't came by a fix so then I read the error logs a little closer and it suggested me to do:

To replace NODE_BINARY=node image with the actual result of the which node command, which in my case looks something like this: image

Also CMD-Shift-K to clean the build folder (just to make sure), then build again, and everything worked fine. This method might come in handy for those who still want to keep nvm.

This worked for me, hope it helps whomever stumbles across this problem.

Thank you @bujoralexandru It's worked for me.

Lexe003 commented 3 years ago

I got the same issue. It's actually horrible.. all mentioned fixed didn't work. Is there a fix coming???

System: OS: macOS 11.3 CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 4.52 GB / 32.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 15.14.0 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 7.7.6 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /Users/yassine/.rvm/rubies/ruby-2.6.6/bin/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.7199119 Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: 11.0.7 - /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

ghiculescualexandru commented 3 years ago

rm -rf ~/.nvm

This works for me!!!!

worked for me, thank you so so much

TheChanDI commented 3 years ago

All mentioned didn't work for me.. Any updates on this ??

girish54321 commented 3 years ago

May be updating xCode will work 0.64 works with out any problem in my work laptop.

lucasGabrielDeAA commented 3 years ago

I have figured out a solution, if you're using nvm make sure you don't have another globally installed version of Node/npm.

If you aren't sure whether or not you have a global version, go to your bash_profile/zshrc and comment the three nvm initialization lines (export NVM_DIR="$HOME/.nvm" [...]), then open a new terminal and do node --version, if it still finds something it means that you have a global version somewhere, and you can find its path with which node.

In my case I'm using Homebrew, and I had a global version of Node that I wasn't even aware coming from the yarn formula, I discovered it after running brew uses --installed node. I went ahead and uninstalled yarn using brew uninstall --force yarn, which automatically uninstalled its node/npm dependency, then uncommented the nvm initialization lines, and then I reinstalled yarn using nvm's npm with npm i -g yarn, and now everything works.

As for a proper resolution on the react-native repo, I suspect that the problem is somehow coming from find-node.sh which is a new file on 0.64. Can't really confirm or propose a solution though. cc @hramos

Worked for me!

johnbowdenatfacet commented 3 years ago

Running fine on simulator, however when running over usb on a physical device or archiving I am getting this error. None of the above solutions work in our instance.

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

johnbowdenatfacet commented 3 years ago

Uninstall NVM and install official node appears to have solved this...

iwmdipak commented 3 years ago

This happened also to me upgrading from 0.63 to 0.64. After trying all solutions with no luck, I found that moving the folder to a directory where the path contain no spaces works and build the app successfully.

Also, make sure you don't have any spaces in the project path

Move the project folder in a path with no spaces (i.e. ~/Dipak/React Native/DemoApp won't work till you have spaces in the path, so move in a path like ~/Dipak/ReactNative/DemoApp)

After delete node_modules and ios/Pods then yarn install && npx pod-install

levymetal commented 3 years ago

After trying everything in this thread to no avail (I use nodenv), I found that I had a rogue ~/.nodenv/shims/.nodenv-shim file. This file is supposed to get cleaned up after a rehash and is used as a guard against parallel rehashing, but in my case a borked rehash must have caused it to stick around. Deleting it resolved the error.

tommulkins commented 3 years ago

This happened also to me upgrading from 0.63 to 0.64. After trying all solutions with no luck, I found that moving the folder to a directory where the path contain no spaces works and build the app successfully.

Also, make sure you don't have any spaces in the project path

Move the project folder in a path with no spaces (i.e. ~/Dipak/React Native/DemoApp won't work till you have spaces in the path, so move in a path like ~/Dipak/ReactNative/DemoApp)

After delete node_modules and ios/Pods then yarn install && npx pod-install

Thanks @iwmdipak! This was the solution that worked for me. 😄

HansBouwmeester commented 3 years ago

Not sure whether I'm alone on this but before the PhaseScriptExecution error is see: cp: /Users/.../Library/Developer/Xcode/DerivedData/.../Build/Products/Debug-iphoneos/main.jsbundle: No such file or directory

React-native 0.64.1 with Xcode 12.5

Zlass commented 3 years ago

I have figured out a solution, if you're using nvm make sure you don't have another globally installed version of Node/npm.

If you aren't sure whether or not you have a global version, go to your bash_profile/zshrc and comment the three nvm initialization lines (export NVM_DIR="$HOME/.nvm" [...]), then open a new terminal and do node --version, if it still finds something it means that you have a global version somewhere, and you can find its path with which node.

In my case I'm using Homebrew, and I had a global version of Node that I wasn't even aware coming from the yarn formula, I discovered it after running brew uses --installed node. I went ahead and uninstalled yarn using brew uninstall --force yarn, which automatically uninstalled its node/npm dependency, then uncommented the nvm initialization lines, and then I reinstalled yarn using nvm's npm with npm i -g yarn, and now everything works.

As for a proper resolution on the react-native repo, I suspect that the problem is somehow coming from find-node.sh which is a new file on 0.64. Can't really confirm or propose a solution though. cc @hramos

This combined with making sure my npm was the latest version (6.14.13 -> 7.14.0) and then deleting my project in ~/Library/Developer/Xcode/DerivedData/ and doing a fresh build seemed to work for me.

khloukrada commented 3 years ago

Yes I am having exactly the same issue with fresh new project. All of the above mentions and fixes not working. Mac OS: 11.4 RN: 0.64.1 Node: 14.13.1 - /Users/username/.nvm/versions/node/v14.17.0/bin/node Yarn: 1.22.10 - /Users/username/.nvm/versions/node/v14.17.0/bin/yarn npm: 6.14.8 - /Users/username/.nvm/versions/node/v14.17.0/bin/npm CocoaPods: 1.10.1 - /usr/local/bin/pod

HansBouwmeester commented 3 years ago

After a lot of messing around I got my setup working again but am not quite sure what exactly made it work.

MacOS: 11.3.1 on Apple M1 RN: 0.64.1 Node: v14.17.0 XCode: 12.5

ahmedawaad1804 commented 3 years ago

it is all about node 1- run npm start manually in terminal ( dont use internal terminal of vs code) 2- run react-native run-ios 3-enjoy note : *please dont use vs code terminal for node env accessability

seasonalmatcha commented 3 years ago

I found this solution on stackoverflow and it worked for me

1-) cd ios 2-) rm -rf Podfile.lock 3-) rm -rf Pods 4-) pod install

victor-carv commented 3 years ago

This happened also to me upgrading from 0.63 to 0.64. After trying all solutions with no luck, I found that moving the folder to a directory where the path contain no spaces works and build the app successfully.

https://github.com/facebook/react-native/issues/31206

This was the issue for me. After moving the project to a folder with a name without spaces it worked

rabamus commented 3 years ago

Been having the same issue and since we work on a wide range of projects and nvm is especially useful for us, I wasn't really content with hardcoding a value for NODE_BINARY or simply removing ~/.nvm altogether for the sake of a single project, especially as more than one person will be required to build this one too.

So after some experimenting with @bujoralexandru's solution I discovered that simply loading nvm ahead of setting NODE_BINARY did the trick!

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
export NODE_BINARY=node
...

react-native-nvm-fix

I haven't tested this without nvm installed but given the check for the existence of ~/.nvm/nvm.sh I would imagine this works regardless of whether nvm is installed or not so it's potentially useful for teams where some users have nvm installed while others don't 🙂

tyson-london commented 3 years ago

I have figured out a solution, if you're using nvm make sure you don't have another globally installed version of Node/npm.

If you aren't sure whether or not you have a global version, go to your bash_profile/zshrc and comment the three nvm initialization lines (export NVM_DIR="$HOME/.nvm" [...]), then open a new terminal and do node --version, if it still finds something it means that you have a global version somewhere, and you can find its path with which node.

In my case I'm using Homebrew, and I had a global version of Node that I wasn't even aware coming from the yarn formula, I discovered it after running brew uses --installed node. I went ahead and uninstalled yarn using brew uninstall --force yarn, which automatically uninstalled its node/npm dependency, then uncommented the nvm initialization lines, and then I reinstalled yarn using nvm's npm with npm i -g yarn, and now everything works.

As for a proper resolution on the react-native repo, I suspect that the problem is somehow coming from find-node.sh which is a new file on 0.64. Can't really confirm or propose a solution though. cc @hramos

This was the solution for me after 6 hours of trying to find the solution. However, in my case all I had to do was uninstall node via HomeBrew and then resintall from the installation package found on the official nodejs site.

redreceipt commented 3 years ago

Does anyone know what's actually setting PREFIX here? I like brew-installed yarn and I don't feel like it should be mutually exclusive with a working react native app.

shxlxa commented 3 years ago

I found this solution on stackoverflow and it worked for me

1-) cd ios 2-) rm -rf Podfile.lock 3-) rm -rf Pods 4-) pod install

works for me

MuhammadUmairMoosani commented 3 years ago

work for me macos: rm -rf ~/.nvm brew cleanup --prune-prefix

hkodes commented 3 years ago

Easy way to Fix this:

1.Go to Menu System Preferences -> Security & Privacy. 2.Choose the Privacy Tab. 3.Select Full Disk Access item in left list. 4.Select Xcode in right list.

gndelia commented 3 years ago

In my case, I was able to solve this issue by setting an alias to default in nvm, instead of unsetting it or nuking nvm

nvm alias "default" "lts/erbium"

I used lts/erbium because I'm in node v12, but other LTS might apply.

luism3861 commented 3 years ago

I found this solution on stackoverflow and it worked for me

1-) cd ios

2-) rm -rf Podfile.lock

3-) rm -rf Pods

4-) pod install

You never delete Podfile.lock, always delete Pods.

1.- rm -rf Pods 2.- rm -rf node_modules 3.- pod install 4.- open Xcode project clean project CMD + K 5.- npm start or yarn start