从#34开始安装React时出错"入门"教程

时间:2016-07-20 20:10:57

标签: ios facebook react-native

我已尝试从" Getting Started"安装React Native。当我运行命令时:

react-native init AwesomeProject

我收到了这个错误,应用程序没有在模拟器中共进午餐。

~/tmp/react-native/AwesomeProject/node_modules/react-native/packager ~
/Users/david/tmp/react-native/AwesomeProject/node_modules/react-native/local-cli/server/formatBanner.js:48
chalkFunction: (fn) => fn,
                    ^^
SyntaxError: Unexpected token =>
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/david/tmp/react-native/AwesomeProject/node_modules/react-native/local-cli/server/checkNodeVersion.js:12:20)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
~ Process terminated. Press <enter> to close the window

我的系统信息:

Mac OS 10.11.6

节点:稳定6.3.0(瓶装),HEAD

守望者:稳定4.6.0(瓶装),HEAD

XCode 7.3.1

感谢您提前

1 个答案:

答案 0 :(得分:0)

我从brew命令安装了节点6.3.0。但是当前节点版本是0.12.7我通过执行以下操作来修复此问题:

  1. brew uninstall node --force
  2. brew install node
  3. (可选,如果你没有nvm)brew install nvm
  4. 仅当您从brew安装了nvm时(步骤3),您必须读取输出brew命令
  5. nvm install v6.3.0
  6. nvm alias default 6.3.0
  7. 之后我就能编译并运行