Failed to start app in Android
Hi, I've followed the guide to try to init AwesomeProject, however, it failed to start with the error
/Users/raymond/workspace/AwesomeProject/node_modules/react-native/packager/transformer.js:32
filename,
^
SyntaxError: Unexpected token ,
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:411:25)
at Object.Module._extensions..js (module.js:446:10)
at Module.load (module.js:353:32)
at Function.Module._load (module.js:308:12)
at Module.require (module.js:363:17)
at require (module.js:382:17)
at process.<anonymous> (/Users/raymond/workspace/AwesomeProject/node_modules/react-native/node_modules/worker-farm/lib/child/index.js:45:34)
at emitTwo (events.js:87:13)
at process.emit (events.js:169:7)
When I check the file transformer.js
const result = babel.transform(src, {
retainLines: true,
compact: true,
comments: false,
filename,
whitelist: [
// Keep in sync with packager/react-packager/.babelrc
'es6.arrowFunctions',
'es6.blockScoping',
'es6.classes',
'es6.destructuring',
'es6.parameters',
'es6.properties.computed',
'es6.properties.shorthand',
'es6.spread',
'es6.templateLiterals',
'es7.asyncFunctions',
'es7.trailingFunctionCommas',
'es7.objectRestSpread',
'flow',
'react',
'react.displayName',
'regenerator',
],
plugins,
sourceFileName: filename,
sourceMaps: false,
extra: options || {},
});
It seems that this json is kinder broken, 'filename' and 'plugins' with nothing?
I'm not sure whether this is related to the error during my project init process:
> node-gyp rebuild
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: 404 status code downloading tarball
gyp ERR! stack at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:246:14)
gyp ERR! stack at emitOne (events.js:82:20)
gyp ERR! stack at Request.emit (events.js:166:7)
gyp ERR! stack at Request.onRequestResponse (/usr/local/lib/node_modules/npm/node_modules/request/request.js:1139:10)
gyp ERR! stack at emitOne (events.js:77:13)
gyp ERR! stack at ClientRequest.emit (events.js:166:7)
gyp ERR! stack at HTTPParser.parserOnIncomingClient (_http_client.js:412:21)
stack at HTTPParser.parserOnHeadersComplete (_http_common.js:88:23)
gyp ERR! stack at Socket.socketOnData (_http_client.js:302:20)
gyp ERR! stack at emitOne (events.js:77:13)
gyp ERR! System Darwin 14.4.0
gyp ERR! command "/usr/local/Cellar/iojs/1.8.1/bin/iojs" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/raymond/workspace/AwesomeProject/node_modules/react-native/node_modules/ws/node_modules/bufferutil
gyp ERR! node -v v1.8.1
gyp ERR! node-gyp -v v1.0.3
gyp ERR! not ok
npm WARN optional dep failed, continuing [email protected]
npm WARN optional dep failed, continuing [email protected]
Thanks!
It seems that this json is kinder broken, 'filename' and 'plugins' with nothing?
It's the ES2015 object shorthand notation. Basically, when both the key and value have the same name, you can just write the name.
Have you tried removing your node_modules folder and running npm install again?
This is most likely caused by the error that occurred during your init. Please try:
$ rm -rf node_modules/
$ npm install
Hopefully this time there won't be an error. Looks like there was a 404 the first time which sounds like an issue with npmjs.com. If all goes well try running this again:
$ react-native run-android
And let us know if it works.
If that doesn't work, try upgrading to Node 4 and installing via nvm, n, etc.
If a request fails to npmjs.org, we should abort the install process and display an appropriate message instead of just continuing on.
In iOS, I meet the same problem. Now, I try to remove the node_modules and Install again.
@foghina Thanks, but no luck, my workaround right now is to explicitly setting filename and plugins to
filename: filename
plugins: plugins
Same issue on IOS
$ rm -rf node_modules/ $ npm install
gives no joy. I'll go with am5a02 for now
Finally, I update & upgrade everything by:
brew update && upgrade
then rebuild the project, Now everything seems OK, perhaps this is the bug for some version.