Build failed error in XCode:
+ DEST=/Users/alekseypokhodnya/Library/Developer/Xcode/DerivedData/rn0471reproduce-fdeyxrhuiruhnzgprfosmoijckya/Build/Products/Release-iphonesimulator/rn0471reproduce.app
+ [[ Release = \D\e\b\u\g ]]
+ BUNDLE_FILE=/Users/alekseypokhodnya/Library/Developer/Xcode/DerivedData/rn0471reproduce-fdeyxrhuiruhnzgprfosmoijckya/Build/Products/Release-iphonesimulator/rn0471reproduce.app/main.jsbundle
+ node /Users/alekseypokhodnya/RubymineProjects/rn047-fail-test/rn0471reproduce/node_modules/react-native/local-cli/cli.js bundle --entry-file index.ios.js --platform ios --dev false --reset-cache --bundle-output /Users/alekseypokhodnya/Library/Developer/Xcode/DerivedData/rn0471reproduce-fdeyxrhuiruhnzgprfosmoijckya/Build/Products/Release-iphonesimulator/rn0471reproduce.app/main.jsbundle --assets-dest /Users/alekseypokhodnya/Library/Developer/Xcode/DerivedData/rn0471reproduce-fdeyxrhuiruhnzgprfosmoijckya/Build/Products/Release-iphonesimulator/rn0471reproduce.app
/Users/alekseypokhodnya/RubymineProjects/rn047-fail-test/rn0471reproduce/node_modules/metro-bundler/src/lib/Terminal.js:141
this._nextStatusStr = util.format(format, ...args);
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Module._extensions..js (module.js:416:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/alekseypokhodnya/RubymineProjects/rn047-fail-test/rn0471reproduce/node_modules/babel-register/lib/node.js:152:7)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Users/alekseypokhodnya/RubymineProjects/rn047-fail-test/rn0471reproduce/node_modules/react-native/local-cli/server/runServer.js:18:18)
at Module._compile (module.js:409:26)
+ [[ false != true ]]
+ [[ ! -f /Users/alekseypokhodnya/Library/Developer/Xcode/DerivedData/rn0471reproduce-fdeyxrhuiruhnzgprfosmoijckya/Build/Products/Release-iphonesimulator/rn0471reproduce.app/main.jsbundle ]]
+ echo 'error: File /Users/alekseypokhodnya/Library/Developer/Xcode/DerivedData/rn0471reproduce-fdeyxrhuiruhnzgprfosmoijckya/Build/Products/Release-iphonesimulator/rn0471reproduce.app/main.jsbundle does not exist. This must be a bug with'
error: File /Users/alekseypokhodnya/Library/Developer/Xcode/DerivedData/rn0471reproduce-fdeyxrhuiruhnzgprfosmoijckya/Build/Products/Release-iphonesimulator/rn0471reproduce.app/main.jsbundle does not exist. This must be a bug with
+ echo 'React Native, please report it here: https://github.com/facebook/react-native/issues'
React Native, please report it here: https://github.com/facebook/react-native/issues
+ exit 2
https://github.com/pohodnya/rn0471_build_ios_release_error_reproduce
what does your babelrc file look like?
This is a critical problem for me. When can you solve it?
I had the exact same problem. But I didn't upgrade my project or anything, it just stopped working.
After I removed my NVM it worked again.
Same problem with Android, stopped our automated pipeline for QA. Critical.
@timvansteenis what you mean removed my NVM?
could you please explain?
thx
@gino8080 I removed my Node Version Manager. I guess the script was somehow using another version of Node.
The script that resulted in the error (when run from XCode) worked fine when i ran it from the terminal. That gave me a clue that it probably wasn't a bug in RN.
This appears to not be a bug in React Native, but a problem with how your environment is setup.
This is the script that xcode uses to determine which binary to use:
https://github.com/facebook/react-native/blob/6e99e314b232c315628c31f97a865c17c071ad23/scripts/react-native-xcode.sh
Notice you can explicitly specify a NODE_BINARY to use via env var. To debug, you can also compare which binary the script is pointing to by using which node inside of this script, and inside your terminal.
Mine for instance works fine like this:
/Users/tabrindle/.nvm/versions/node/v7.10.0/bin/node
@tabrindle yes, you are right. I find in my nvm list [email protected] with default alias.
Yes you are right.
As a result, the following steps helped for me
sudo rm -rf /usr/local/{lib/node{,/.npm,_modules},bin,share/man}/{npm*,node*,man1/node*}nvm install v6.10.0nvm alias default 6.10.0Glad I could help! Thanks for documenting what you did.
I had this issue as well when I tried to create an archive in Xcode.
For me, it was because the command to build the JS bundle was failing, and the reason it was failing was because one of my dependencies had a specific babel preset in its .babelrc file, which I did not have installed in my main React Native project's package.json.
In the Xcode error output, a few lines above the "main.jsbundle does not exist" line, I had the following error message from the react-native bundle command that had run:
TransformError: /Users/jordan/Development/MyAppName/node_modules/dotenv-parse-variables/lib/index.js: Unknown plugin "add-module-exports" specified in "/Users/jordan/Development/MyAppName/node_modules/dotenv-parse-variables/.babelrc" at 0, attempted to resolve relative to "/Users/jordan/Development/MyAppName/node_modules/dotenv-parse-variables"
So I installed the missing plugin by running: yarn add --dev babel-plugin-add-module-exports
I then went to Xcode again, did a Product -> Clean, then Product -> Archive, and this time it worked.
I actually used to have these dependency-related babel plugins installed, but I removed them because the release notes for 0.50.0 (https://github.com/facebook/react-native/releases/tag/v0.50.0) stated that this wouldn't be required anymore due to the change in enableBabelRCLookup. But I guess that change isn't quite working correctly, so for now we'll have to keep using the workaround I used here, or the postinstall workaround that they describe in those release notes.
For reference, here's my dependencies:
"react": "16.0.0",
"react-native": "0.50.3"
I had to change .babelrc file to :
{
"presets": ["react-native"],
"plugins": ["transform-decorators-legacy"],
"sourceMaps": true
}
Most helpful comment
This is a critical problem for me. When can you solve it?