When trying to eject app to "Native" syntax error is thrown and ejection process exits.
answer all questions in process, then native app is ejected properly.
After being asked what type of ejection I want to run (native vs expo), syntax error is thrown and process exits
If there's an error message, please paste the full terminal output and error message in this code block:
Error running eject: SyntaxError: Unexpected token } in JSON at position 487
Please run these commands in the project folder and fill in their results:
npm ls react-native-scripts:[email protected]npm ls react-native: [email protected]npm ls expo: [email protected]node -v: 7.8.0npm -v: 4.2.0yarn --version: 0.19.1watchman version: 4.7.0Also specify:
new project works fine
Hi! Thanks for the report! Which option did you choose to eject?
I am trying to eject to a "raw" native app. If I knew what JSON it was referring to I could look specifically to try an fix, but I couldn't find anything with a issue that I could see. Thanks for the quick response!
Can you paste the contents of app.json and package.json?
app.json
{
"expo": {
"sdkVersion": "15.0.0",
"icon": "./img/logo.png",
"slug": "Logo",
"loading": {
"hideExponentText": true,
"icon": "./img/loading.png",
"backgroundImage": "./img/logo.png"
},
"orientation": "portrait",
"primaryColor": "#cccccc",
"packagerOpts": {
"assetExts": [
"ttf"
]
},
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.onepxoff.test",
},
"android": {
"package": "com.onepxoff.test",
},
"androidStatusBarColor": "#EEE",
"androidStatusBar": {
"barStyle": "dark-content",
"backgroundColor": "#EEE",
}
}
I actually think I just figured it out, however I think this is a problem that could be more clear in the error.
I opened the json file in another editor and it showed me some "errors" with the json. basically the trailing , on lines like "bundleIdentifier": "com.onepxoff.test" are causing technically invalid json
Ah, yeah, that'll do it. I don't think we're parsing using json5. I agree the error message could be much clearer, I've updated the issue title to reflect that.
thanks for the help. I was able to eject the app now. Not sure if you want to close this issue or keep it open to help clear up the error message.
Let's leave it open, I'd like to improve this!
I am getting this error while eject project with expo-sdk.
Error running eject: SyntaxError: Unexpected token } in JSON at position 805
hi, I just got the exact same error and removing a trailing comma, like @n8stowell82 suggested, fixed the issue.
also got this error, and fixed by removing trailing comma of app.json
@anp would you accept a PR using https://github.com/json5/json5 for safer parsing? Or wrapping the parse calls and throwing more contextual exceptions?
I don't really see a downside to that, cc @fson.
It would be enough to change the eject functionality to use XDL.ProjectUtils.readConfigJsonAsync instead of doing raw JSON.parse like it does now. This function in XDL uses this library https://github.com/expo/json-file for parsing JSON files. It uses the json5 parser and also throws contextual syntax errors.