New project not working on IOS Xcode 12.4 react-native 0.64 (Command PhaseScriptExecution failed with a nonzero exit code)
Please provide all the information requested. Issues that do not follow this format are likely to stall.
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
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)
"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
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
ngocdaothanh, KatiRasanen, suman-vanan, sgrishanin, Yonom, rachhen, alimtunc, nwalters512, rdsedmundo, andrefangeloni, and 29 more reacted with thumbs up emoji
LouiseReid, smamahasn, thebabyjay, ShubhamBathe-KM, and harmit001 reacted with thumbs down emoji
andrefangeloni, tvpranav, TheScudMissile, wizz92, Jonathan0wh, aronmi, AliRehman7141, MarioSilvaPrada, lfoliveir4, chmtt, and younesshakky reacted with hooray emoji
andrefangeloni, TheScudMissile, wizz92, Jonathan0wh, AliRehman7141, MarioSilvaPrada, lfoliveir4, chmtt, and Firdavs00 reacted with rocket emoji
All reactions
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
jeancatarina, 0scrm, apolubek, deyvisonpenha, sturmenta, onebigdoor, axelinternet, raghiii, godievski, julio-abenathar, and 75 more reacted with thumbs up emoji
vanGalilea, TheChanDI, axelinternet, santhoshv97, gndelia, mohitkmr170, AliRehman7141, BondarevskiyE, chenweigh, FakhruddinAbdi, and 7 more reacted with thumbs down emoji
elliotdickison, QC-L, dhavalMindinventory, ninnemannk, LRNZ09, henriquebarrosx, makarkotlov, vanhai989, cue28, ogbodo, and 3 more reacted with laugh emoji
jeancatarina, apolubek, deyvisonpenha, nubo94, Saad-Bashar, sturmenta, onebigdoor, axelinternet, raghiii, julio-abenathar, and 26 more reacted with hooray emoji
jeancatarina, apolubek, deyvisonpenha, Orta21, Saad-Bashar, sturmenta, onebigdoor, axelinternet, raghiii, julio-abenathar, and 27 more reacted with heart emoji
jeancatarina, apolubek, deyvisonpenha, ChristopherBartalos, Saad-Bashar, sturmenta, onebigdoor, axelinternet, julio-abenathar, Arthuron, and 20 more reacted with rocket emoji
All reactions
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
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
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
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 🤔
ilyavf, JeffreyLeeDave, aundus, cruinh, yoalix, sammiepls, and karenhakobyan114 reacted with thumbs up emoji
Heltonphg reacted with thumbs down emoji
All reactions
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
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
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
tvtruong3964, lucasGabrielDeAA, gcottrell1, mbilello10, alyssoncm, Arthuron, wizz92, redreceipt, emilegaspi, mzakov, and 11 more reacted with thumbs up emoji
rdonnelly, jwoodrow, DigitalEpidemic, momsse, zees98, sturmenta, lucasGabrielDeAA, gcottrell1, sznrbrt, alyssoncm, and 9 more reacted with heart emoji
sturmenta, tvtruong3964, lucasGabrielDeAA, christiandrey, alyssoncm, wizz92, mzakov, SpookyUmi, AliRehman7141, 29er, and Brad19 reacted with rocket emoji
All reactions
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.
ghiculescualexandru, JuanJMendoza, dennismunene, CptFabulouso, TommyLeong, yujin113, haryelramalho, BlindDev, miversen, eduardofinotti-james, and 10 more reacted with thumbs up emoji
dima888, erenerdemli, adamelliotfields, HansBouwmeester, JijoBose, sznrbrt, yakovlevgleb, kyujonglee, b-derksen, Diekrul, and 9 more reacted with thumbs down emoji
ShaheerAliKhan, pedenys, SCasarotto, and yogesh061 reacted with laugh emoji
alysonliu, ghiculescualexandru, JuanJMendoza, eduardofinotti-james, and SCasarotto reacted with hooray emoji
JuanJMendoza, arthurliebhardt, eduardofinotti-james, and SCasarotto reacted with rocket emoji
All reactions
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
with the actual result of the which node command, which in my case looks something like this:
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.
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
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!
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
with the actual result of the which node command, which in my case looks something like this:
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.
Per this article I used: nvm unalias default and my app is now running. Yay
Where should I run this command?
Run it from CLI
where $RN_DIR is undefined.
Replace source "$RN_DIR/scripts/find-node.sh" with source "$REACT_NATIVE_DIR/scripts/find-node.sh" solves the issue.
Relates to 322e8f7
This is resolved in the latest version of react-native (0.66.1)
I had the same issue and solved it by navigating to: your app target -> Build Phases -> Bundle React Native code and images:
The fix for me was changing the "export NODE_BINARY" value to the above value which I got from running which node in the terminal.
Basically, what you want there is the path to your node binary. Whether you're using nvm or not, it shouldn't matter.
For those having this issue, I'm using NVM, I found the path of node I had active in NVM and symlinked it to /usr/local/bin/node. The other solutions above didn't work where you export NODE_BINARY etc. This fix is more of a workaround and will need to be adjusted over time / removed. Not ideal, but it works.
% which node
/Users/luke/.nvm/versions/node/v14.17.5/bin/node
sudo ln -s /Users/luke/.nvm/versions/node/v14.17.5/bin/node /usr/local/bin/node
Summary:
Some users have `node` installed globally which sets a `PREFIX` by default (so it knows where to put pkgs). We are looking for the "right" node on the next step anyway and if the user is using `nvm`, `PREFIX` breaks it.
closes facebook#31181
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
[General] [Fixed] - Ignores global npm prefix
Pull Request resolved: facebook#31740
Test Plan:
`yarn ios` now works, even if there's a `usr/local/bin/npm`
<img width="493" alt="Screen Shot 2021-06-17 at 10 14 08 AM" src="https://user-images.githubusercontent.com/2659478/122413946-c2f57200-cf54-11eb-817c-bd3c07ac50bf.png">
Reviewed By: yungsters
Differential Revision: D31237363
Pulled By: charlesbdudley
fbshipit-source-id: 4ee9c04f8b8ab4e815bafbe2d02e589d621577b4
Summary:
Some users have `node` installed globally which sets a `PREFIX` by default (so it knows where to put pkgs). We are looking for the "right" node on the next step anyway and if the user is using `nvm`, `PREFIX` breaks it.
closes facebook#31181
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
[General] [Fixed] - Ignores global npm prefix
Pull Request resolved: facebook#31740
Test Plan:
`yarn ios` now works, even if there's a `usr/local/bin/npm`
<img width="493" alt="Screen Shot 2021-06-17 at 10 14 08 AM" src="https://user-images.githubusercontent.com/2659478/122413946-c2f57200-cf54-11eb-817c-bd3c07ac50bf.png">
Reviewed By: yungsters
Differential Revision: D31237363
Pulled By: charlesbdudley
fbshipit-source-id: 4ee9c04f8b8ab4e815bafbe2d02e589d621577b4
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
Hi @Yonom,
how did you discover that in your the reason was 'nvm is not compatible with the "PREFIX" environment variable: currently set to "/usr/local" '
I've uninstalled nvm as well, but still error happens while it's running custom shell script 'Bundle React Native code and images' -> ERROR: Command PhaseScriptExecution failed with a nonzero exit code
Could you please help me?
Many thanks
Stefano
Fantastic and insightful comments here, which led to my solution.
I'll add my specific solution to the pot: in my case, I also had nodenv installed, not sure how or why, I don't remember, I've always been an nvm user. (Great that we have two tools for the exact same task out there 🙄) anyway, I nuked it:
But then I still had to do:
rm -R /Users/myuser/.nodenv/
And even then I still had to manually remove this line in my .zshrc (NOT .zprofile):
eval "$(nodenv init -)"
Whew, builds working again in XCode 😅
Summary:
Some users have `node` installed globally which sets a `PREFIX` by default (so it knows where to put pkgs). We are looking for the "right" node on the next step anyway and if the user is using `nvm`, `PREFIX` breaks it.
closes facebook#31181
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
[General] [Fixed] - Ignores global npm prefix
Pull Request resolved: facebook#31740
Test Plan:
`yarn ios` now works, even if there's a `usr/local/bin/npm`
<img width="493" alt="Screen Shot 2021-06-17 at 10 14 08 AM" src="https://user-images.githubusercontent.com/2659478/122413946-c2f57200-cf54-11eb-817c-bd3c07ac50bf.png">
Reviewed By: yungsters
Differential Revision: D31237363
Pulled By: charlesbdudley
fbshipit-source-id: 4ee9c04f8b8ab4e815bafbe2d02e589d621577b4
i fixed it
go to your terminal write nano .profile remove everything and save it
run the build and it will work.
this was happening because of environment variables conflict of NVM set in .profile
I did several things so it's hard to know which one did it:
Make sure you don't have errors in your bash or zshrc profile -> I had a error related to my jdk. You will know this if it when opening a terminal window it shows an error/warning
Make sure you don't have spaces in the path
If you are using Firebase, make sure your GoogleService-Info file is in the ios folder and not in the ios>project folder
Do not keep the project in an iCloud folder, especially if you are low on space. I suspect this was a big factor for mine.
Finally, my worked when doing these and running react-native 0.67.2. The newer version on it's own didn't fix it, I had to do at least one of these other assertions to get it working
Things to consider:
Running the project in Xcode will usually give you more insight into the problem
Clearing the Xcode build folder wasn't enough on it's own to fix it but when trying a potential solution it is important you do it (and potentially also pod deintegrate && pod install) to make sure there are no traces of the previous ios build.
I am running node version 16.13, running node 17 gave me different errors and I wouldn't recommend it to date.
I am running macOS Monterrey and Xcode 13.2.1, but I tried on BigSur and also Xcode 12.5.1 and the still got the error.
For those having this issue, I'm using NVM, I found the path of node I had active in NVM and symlinked it to /usr/local/bin/node. The other solutions above didn't work where you export NODE_BINARY etc. This fix is more of a workaround and will need to be adjusted over time / removed. Not ideal, but it works.
% which node
/Users/luke/.nvm/versions/node/v14.17.5/bin/node
sudo ln -s /Users/luke/.nvm/versions/node/v14.17.5/bin/node /usr/local/bin/node
Thank you so much, this solved my problem! I have node (v16.14.0) installed via brew and don't use nvm at all. I encountered this problem after upgrading from React Native v0.66.4 to v0.67.3.
Thank you so much, this solved my problem! I have node (v16.14.0) installed via brew and don't use nvm at all.
Thanks!
I solved my problem the same way.
$ which node
/Users/xxxx/.nodebrew/current/bin/node
$ ln -s /Users/xxxx/.nodebrew/current/bin/node /usr/local/bin/node
For those having this issue, I'm using NVM, I found the path of node I had active in NVM and symlinked it to /usr/local/bin/node. The other solutions above didn't work where you export NODE_BINARY etc. This fix is more of a workaround and will need to be adjusted over time / removed. Not ideal, but it works.
% which node
/Users/luke/.nvm/versions/node/v14.17.5/bin/node
sudo ln -s /Users/luke/.nvm/versions/node/v14.17.5/bin/node /usr/local/bin/node
Thanks!
I solved my problem the same way.
Instead of removing nvm or removing nvm's default alias one could simple patch react-native's node_modules.
Update node_modules/react-native/scripts/find-node.sh around line 22 - 28
if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
# shellcheck source=/dev/null
- . "$HOME/.nvm/nvm.sh"
+ . "$HOME/.nvm/nvm.sh" --no-use
+ nvm use 2> /dev/null || nvm use default
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
# shellcheck source=/dev/null
- . "$(brew --prefix nvm)/nvm.sh"
+ . "$(brew --prefix nvm)/nvm.sh" --no-use
+ nvm use 2> /dev/null || nvm use default
In a completely freshly initialized project generated via npx react-native init AwesomeProject with react-native 0.67.3, I'm still unable to build. I've tried manually setting the path to my nvm node via the xcode interface as well as symlinking it overtop /usr/local/bin/node to no avail.
My node_modules/react-native/scripts/find-node.sh already looks like the recommended version above in #31181 (comment)
Building via npx react-native run-ios also fails:
PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/redacted/Library/Developer/Xcode/DerivedData/AwesomeProject-exgrnhoygfclvdfgqamnrudobewd/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FBReactNativeSpec.build/Script-5F4C70EF7D90A5A5BDAEB404279F232A.sh (in target 'FBReactNativeSpec' from project 'Pods')
(1 failure)
Monterey 12.2.1 (21D62)
Xcode Version 13.2.1 (13C100)
Node v16.14.0 (installed via nvm)
React Native 0.67.3
@alancwoo did you install cocoapods via gem (i.e. sudo gem install cocoapods)? If so try installing via brew.
First remove cocoapods with sudo gem uninstall cocoapods and then run brew install cocoapods.
If you're still having issues try sudo gem install ffi it may help with pod optimisations.
I had issues with installing pods when using cocoapods installed via gem. I think it's a rossetta issue.
I am running the exact same setup:
Monterey 12.2.1 (21D62)
Xcode Version 13.2.1 (13C100)
Node v16.14.0 (installed via nvm)
React Native 0.67.3
I ran into this failure too. I also debugged it down to the . "$HOME/.nvm/nvm.sh" line. However, I came up with a different solution. For me, mine was failing because nvm's default was pointing to an uninstalled version. If I set nvm's default to an installed version, like nvm alias default v14 then it started to work
I just had a similar issue. I had previously had this issue and nvm unalias default got me around it.
This time that approach did not fix it. I started to re-create the steps that were happening on that PhaseScriptExecution and I believe the find_node.sh script it uses was exited the shell (I could see my iTerm2 tab disappear every time I tried to run it).
I ended up upgrading nvm using the Upgrade Instructions and I was finally able to successfully build.
For those having this issue, I'm using NVM, I found the path of node I had active in NVM and symlinked it to /usr/local/bin/node. The other solutions above didn't work where you export NODE_BINARY etc. This fix is more of a workaround and will need to be adjusted over time / removed. Not ideal, but it works.
% which node
/Users/luke/.nvm/versions/node/v14.17.5/bin/node
sudo ln -s /Users/luke/.nvm/versions/node/v14.17.5/bin/node /usr/local/bin/node
This solved for me using nvm and node 16.16.0
xcode 13.4.1
react-native 0.68.2
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 truely worked for me..
Since I'm using M2 macbook pro and building the ios and android via fastlane, i encountered this issue and unsure what to do. I was looking out every where for the solution, finally I found this, based on that i realised that i've installed yarn via brew and not via npm. so uninstalling the yarn and re-installing via npm -g made a big difference. It made my day. Thanks for this
post.
Cheers,