react-native init AwesomeProject
is throwing SyntaxError: Unexpected token :
and I'm not sure why. I've uninstalled and re-installed react-native-cli. Tried with and without yarn
. Any suggestions?
mes-MBP:myproject me$ react-native init AwesomeProject
This will walk you through creating a new React Native project in /Users/me/WebstormProjects/myproject/AwesomeProject
Using yarn v0.17.10
Installing react-native...
/Users/me/WebstormProjects/myproject/AwesomeProject/node_modules/react-native/local-cli/util/Config.js:43
cwd: string,
^
SyntaxError: Unexpected token :
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at loader (/Users/me/WebstormProjects/myproject/AwesomeProject/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/me/WebstormProjects/myproject/AwesomeProject/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/me/WebstormProjects/myproject/AwesomeProject/node_modules/react-native/local-cli/cliEntry.js:13:16)
at Module._compile (module.js:413:34)
Looks like the error an update was published to
react-native
. Others are experiencing the same issue so I'm going to answer this and say it's a package issue. https://github.com/facebook/react-native/issues/11384Until this gets resolved, you can use
rninit
(https://www.npmjs.com/package/rninit) to install using the previous version ofreact-native
. This worked for me:rninit init mobile --source react-native@0.39.0
Update node version on OS.
Apparently the new version React Native
0.56.0
has this problem.To fix this problem, you can install the previous version.