`react-native init AwesomeProject`抛出SyntaxError

时间:2016-12-09 01:13:14

标签: react-native react-native-cli

react-native init AwesomeProject投掷SyntaxError: Unexpected token :,我不确定原因。我已经卸载并重新安装了react-native-cli。尝试使用和不使用yarn。有什么建议吗?

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)

3 个答案:

答案 0 :(得分:2)

看起来更新发布到react-native的错误。其他人也遇到了同样的问题,所以我要回答这个问题并说这是一个包问题。 https://github.com/facebook/react-native/issues/11384

在此问题得到解决之前,您可以使用rninithttps://www.npmjs.com/package/rninit)使用之前版本的react-native进行安装。这对我有用:
rninit init mobile --source react-native@0.39.0

答案 1 :(得分:0)

在操作系统上更新节点版本。

type
critical::issue::A      2
critical::issue::B      1
hardware::issue::B      1
software::      0

答案 2 :(得分:0)

显然,新版本React Native 0.56.0遇到了这个问题。

要解决此问题,您可以安装以前的版本。

react-native init --version="0.55.0" MyNewApp