diff --git a/packages/react-native/scripts/cocoapods/utils.rb b/packages/react-native/scripts/cocoapods/utils.rb index 706e6f344ba..869389eaefb 100644 --- a/packages/react-native/scripts/cocoapods/utils.rb +++ b/packages/react-native/scripts/cocoapods/utils.rb @@ -235,16 +235,9 @@ class ReactNativePodsUtils if !file_manager.exist?("#{file_path}.local") # When installing pods with a yarn alias, yarn creates a fake yarn and node executables # in a temporary folder. - # Using `type -a` we are able to retrieve all the paths of an executable and we can - # exclude the temporary ones. + # Using `node --print "process.argv[0]";` we are able to retrieve the actual path from which node is running. # see https://github.com/facebook/react-native/issues/43285 for more info - node_binary = `type -a node`.split("\n").map { |path| - path.gsub!("node is ", "") - }.select { |b| - !b.start_with?("/var") - } - - node_binary = node_binary[0] + node_binary = `node --print "process.argv[0]";` system("echo 'export NODE_BINARY=#{node_binary}' > #{file_path}.local") end end