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

ElForastero commented 3 years ago

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

Nothing helps.

Xcode 12.4 Big Sur Intel Node 15

brandonpearcy commented 3 years ago

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.

N1colasVega commented 3 years ago

after this trick i got this: CompileC /Users/user/Library/Developer/Xcode/DerivedData/AwesomeProject-btdlvrsshpcfmndosfollajacgcx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-RCTVibration.build/Objects-normal/x86_64/RCTVibration.o /Users/pavelsytniakovskyi/Documents/React\ Native/AwesomeProject/node_modules/react-native/Libraries/Vibration/RCTVibration.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler

111041177-48b4cf00-83f4-11eb-89a6-9847e3f84259

also i noticed this

Screenshot 2021-03-15 at 14 24 20

So, still no answers?

geraintwhite commented 3 years ago

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.

Aljishim1 commented 3 years ago

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.

kristijantomic commented 3 years ago

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

EHRdev commented 3 years ago

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?

ElForastero commented 3 years ago

could you solve it?

Unfortunately no :(

hyochan commented 3 years ago

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

marudy commented 3 years ago

Same issue here, looks like it's connected with the issues we faced on the Road to v0.64 Discussion #214 issue:

Screenshot 2021-03-21 at 16 04 45
>>>>> Generating schema from flow types

/Users/tasosmaroudas/yolo/github/inside-labs/omni/node_modules/react-native-codegen/lib/parsers/flow/index.js:220
    const regex = new RegExp(TURBO_MODULE_REGISTRY_REQUIRE_REGEX_STRING, 'g');
                  ^

SyntaxError: Invalid regular expression: /TurboModuleRegistry\s*\.\s*get(Enforcing)?\s*<\s*Spec\s*>\s*\(\s*['"](?<nativeModuleName>[A-Za-z$_0-9]+)['"]\s*,?\s*\)/: Invalid group
    at new RegExp (<anonymous>)
    at buildSchema (/Users/tasosmaroudas/yolo/github/inside-labs/omni/node_modules/react-native-codegen/lib/parsers/flow/index.js:220:19)
    at Object.parseFile (/Users/tasosmaroudas/yolo/github/inside-labs/omni/node_modules/react-native-codegen/lib/parsers/flow/index.js:276:10)
    at files.reduce (/Users/tasosmaroudas/yolo/github/inside-labs/omni/node_modules/react-native-codegen/lib/cli/combine/combine-js-to-schema.js:75:35)
    at Array.reduce (<anonymous>)
    at combineSchemas (/Users/tasosmaroudas/yolo/github/inside-labs/omni/node_modules/react-native-codegen/lib/cli/combine/combine-js-to-schema.js:66:16)
    at Object.<anonymous> (/Users/tasosmaroudas/yolo/github/inside-labs/omni/node_modules/react-native-codegen/lib/cli/combine/combine-js-to-schema-cli.js:90:40)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Module.load (internal/modules/cjs/loader.js:566:32)
Command PhaseScriptExecution failed with a nonzero exit code

Libtool /Users/tasosmaroudas/Library/Developer/Xcode/DerivedData/omni-fevwfpyebixpcpdoffjgdtusphxs/Build/Products/Debug-iphonesimulator/RNFBMessaging/libRNFBMessaging.a normal (in target 'RNFBMessaging' from project 'Pods')
    cd /Users/tasosmaroudas/yolo/github/inside-labs/omni/ios/Pods
    export IPHONEOS_DEPLOYMENT_TARGET\=9.0
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only x86_64 -D -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator14.2.sdk -L/Users/tasosmaroudas/Library/Developer/Xcode/DerivedData/omni-fevwfpyebixpcpdoffjgdtusphxs/Build/Products/Debug-iphonesimulator/RNFBMessaging -filelist /Users/tasosmaroudas/Library/Developer/Xcode/DerivedData/omni-fevwfpyebixpcpdoffjgdtusphxs/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RNFBMessaging.build/Objects-normal/x86_64/RNFBMessaging.LinkFileList -dependency_info /Users/tasosmaroudas/Library/Developer/Xcode/DerivedData/omni-fevwfpyebixpcpdoffjgdtusphxs/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RNFBMessaging.build/Objects-normal/x86_64/RNFBMessaging_libtool_dependency_info.dat -o /Users/tasosmaroudas/Library/Developer/Xcode/DerivedData/omni-fevwfpyebixpcpdoffjgdtusphxs/Build/Products/Debug-iphonesimulator/RNFBMessaging/libRNFBMessaging.a
** BUILD FAILED **

The following build commands failed:
    PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/tasosmaroudas/Library/Developer/Xcode/DerivedData/omni-fevwfpyebixpcpdoffjgdtusphxs/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-B34018C2B1ECE620432B6A01A1CDBB2D.sh
(1 failure)
smacgregor commented 3 years ago

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

parveen-bhatia commented 3 years ago

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.

mikeportanova commented 3 years ago

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.

N1colasVega commented 3 years ago

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 reinstalled whole environment, tried to do it through bash and zsh, have the same results

System: OS: macOS 11.2.2 CPU: (8) x64 Apple M1 Memory: 82.81 MB / 8.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 14.16.0 - /usr/local/bin/node Yarn: Not Found npm: 6.14.11 - /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: 28, 29, 30 Build Tools: 28.0.3, 29.0.0, 29.0.2, 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.7042882 Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: 1.8.0_242-release - /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

N1colasVega commented 3 years ago

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

SpawnAtis 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
JB-CHAUVIN commented 3 years ago

Same issue goes for me...

I have the following error when building with CLI or XCODE 12 :

Cycle in dependencies between targets 'XXX' and 'FBReactNativeSpec'; building could produce unreliable results.
Cycle path: XXX → FBReactNativeSpec → XXX
Cycle details:
→ Target 'XXX': CodeSign /Users/USER/Library/Developer/Xcode/DerivedData/XXX-gmygnlcxpxbgnjhbiucdcnkhkmfv/Build/Products/Debug-iphonesimulator/Docavenue.app
○ Target 'XXX': ProcessProductPackaging  /Users/USER/Library/Developer/Xcode/DerivedData/XXX-gmygnlcxpxbgnjhbiucdcnkhkmfv/Build/Intermediates.noindex/Docavenue.build/Debug-iphonesimulator/XXX.build/XXX.app.xcent
○ Target 'XXX' has target dependency on Target 'FBReactNativeSpec'
○ That command depends on command in Target 'FBReactNativeSpec': script phase “[CP-User] Generate Specs”
→ Target 'FBReactNativeSpec' has copy command from '/Users/USER/Maiia/Mobile/maiia-mobile-develop/node_modules/react-native/React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h' to '/Users/USER/Library/Developer/Xcode/DerivedData/XXX-gmygnlcxpxbgnjhbiucdcnkhkmfv/Build/Products/Debug-iphonesimulator/FBReactNativeSpec/FBReactNativeSpec.framework/Headers/FBReactNativeSpec.h'
○ That command depends on command in Target 'FBReactNativeSpec': script phase “[CP-User] Generate Specs”
mzu commented 3 years ago

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.

chadhobson commented 3 years ago

I had this same error in our monorepo before having a "duh" moment and remembering I have to update the react-native dependency in all the package.json files to match.

Needless to say, React Native doesn't update often enough for me to remember this.

Anyway, this fIxed the issue for me so I'm just leaving this comment in the off chance it saves someone else some time.

giuseppealbrizio 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:

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

ge6285790 commented 3 years ago

I had the same issue, and I found that because I use nvm to control my node version and I added different node version in .zshrc and .bash_profile file.

In /Users/xxxxx/.bash_profile, I added "nvm use --delete-prefix v7.2.0", but in /Users/xxxxx/.zshrc I added "nvm use --delete-prefix v12.21.0".

After change two files to the same node version (nvm use --delete-prefix v12.21.0), my project can build successfully.

allindeveloper commented 3 years ago

Thanks for pointing this out @giuseppealbrizio it fixed my issue

eugenehp commented 3 years ago

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.

itzpradip 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

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.

troZee commented 3 years ago

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

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

aram-yesildeniz commented 3 years ago

Downgrading node to < 15 worked for me

likeaj6 commented 3 years ago

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
  )
srikanthflyitout 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 resolved my issue

ha-family commented 3 years ago

it works after upgrade my nvm version with brew upgrade nvm

Andriiklymiuk commented 3 years ago

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

luisfuertes commented 3 years ago

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

this resolved all of my issues:

nvm unalias default

vjpr commented 3 years ago

If using nvm try:

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

From: http://stackoverflow.com/a/50419734/130910

mrbrentkelly commented 3 years ago

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.

reyanshmishra commented 3 years ago

Even I have the same issue any progress?

Villar74 commented 3 years ago

Got same error. Nothing from this issue helped me. I fixed this problem by creating new user on my mac. IOS app began building again in Xcode. I will make some more research what was the reason. I guess its because of bad development environmet setup.

jamiehaywood commented 3 years ago

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

marcoisgood commented 3 years ago

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.

marcoisgood commented 3 years ago

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.

jineous27 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?
  1. Remove the space in the folder from IT Project => IT_Projects & Moved project to the IT_Projects folder
  2. I've checked the react-native version. It's already updated to the latest version (0.64). So I skip it
  3. 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)
reyanshmishra commented 3 years ago

I was able to fix the problem by remove nodejs and nvm and npm completely from my system and reinstalling it. I used this script to install fresh install node. https://gist.github.com/brock/5b1b70590e1171c4ab54

Villar74 commented 3 years ago

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

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

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

alexisbronchart commented 3 years ago

I'm also having this issue but only when I run the build from the cli. Building in Xcode works just fine. I managed to get to output of the script:

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

Not sure what to make of this though. For now I removed nvm and it works.

mfpkb commented 3 years ago

I was getting following error on this line of generate-specs.sh

Error: Cannot find module 'react-native-codegen/package.json'

Using latest generate-specs.sh from master worked for me

mathew3 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

t18n commented 3 years ago

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?

DevdudeSami commented 3 years ago

Difference solutions seem to work for different people so what worked for me earlier today was to delete the react-native folder in node_modules then run npm i again.

Didn't update react-native recently or anything; the error just started coming up at a random time.

oxsource commented 3 years ago

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.

确实解决了问题(node env problem, it works for me, thanks!)