We've come across some issues, where a React Native build would fail, stating that the Node version is incompatible with the Node version on our Build Agents.
It is possible that the newer libraries require Node to be at least a specific version or greater.
At the time of writing this, the Node version on our Agents was 6.12.3 (We updated the installed software versions of the Agents here).
If you come across a failure like this in your React Native builds, consider adding a "Post-Clone" script (filename: appcenter-post-clone.sh)
#!/usr/bin/env bash
set -ex
brew uninstall node@6
NODE_VERSION="8.9.4"
curl "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}.pkg" > "$HOME/Downloads/node-installer.pkg"
sudo installer -store -pkg "$HOME/Downloads/node-installer.pkg" -target "/"
Replace the value of NODE_VERSION with the exact one you want.
What we're essentially doing is uninstalling node version (6) and installing the node version we want on the Agent, based on the error message. We're doing this in the Post-Clone script as it runs immediately after the repository was cloned but before we do anything else on our end.
Note : If you are using RN 0.56.0 later, you'd be forced to use Node 8.12, you will see these lines in the Build logs,
Now using node v8.12.0 (npm v6.4.1)
default -> node8 (-> v8.12.0 *)
If you want to force us to select the Node version you want, you can do so by modifying the post-clone script to,
#!/bin/sh
# please specify required Node.js version
NODE_VERSION=8.10.0
# workaround to override the v8 alias
npm config delete prefix
. ~/.bashrc
nvm install "$NODE_VERSION"
nvm alias node8 "$NODE_VERSION"
This way, you can make use of our powerful build scripts to setup/fix up the Agents' environment based on your App requirements.
PS: Whenever you make a change to these build scripts, ensure you do a "re-save" on the Build Configuration for App Center to pick it up again. A current feature - limitation at our side.
Cheers!