'Xcode Build react native code and images not finding node

I am trying to build react native ios release app but I am getting an error because Xcode can't see node binary,

in the Build react native code and images section in Xcode, I am exporting NODE_BINARY=node this way:


export EXTRA_PACKAGER_ARGS="--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map"
export NODE_BINARY=node
../node_modules/react-native/scripts/react-native-xcode.sh

but it didn't work because Xcode can't find node binary.

so when I changed NODE_BINARY from node to:

export NODE_BINARY=/opt/homebrew/bin/node

it works well this way, but I can't export it this way because the testers team have the node bin in another directory.

so I exported a variable in .zshrc file called NODE_CLI but I don't know how to use it in Xcode for example:

export NODE_BINARY=$NODE_CLI

or

export NODE_BINARY=$($NODE_CLI)

or

export NODE_BINARY=${NODE_CLI}

any suggestions?

thank you🙏.



Solution 1:[1]

instead of directly passing the node variable, you can leave it to xcode to discern which node you're using by implying it, do this instead:

export NODE_BINARY=$(which node)

Found pointers for this on several SO answers and it's given me no issues

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Fiyifoluwa