无法在模拟器中启动反应原生应用程序
问题描述:
我正在尝试关注官方react-native tutorial。一切都很好,直到我尝试运行该项目。然后bash脚本与以下错误消息无法在模拟器中启动反应原生应用程序
~/react_sites/AwesomeProject/node_modules/react-native/packager ~
/Users/Chris/react_sites/AwesomeProject/node_modules/react-native/local-cli/cli.js:74
const setupEnvScript = /^win/.test(process.platform)
^^^^^
SyntaxError: Use of const in strict mode.
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
~
Process terminated. Press <enter> to close the window
弹出并模拟器给出了Could not connect to development server
错误。我该如何解决?
我正在使用Xcode 7.2。
答
我会假设你有pre-requisites,但在移动之前仔细检查。 Homebrew,Watchman,Node 4+和Flow(可选)。
当您在Xcode中打开项目并按下构建按钮(play?)时,它应该自动启动包装器服务器。但在你的情况下,似乎没有。在这种情况下,请在构建项目之前在项目的根目录中尝试在终端中运行npm start
。
答
我想你使用的是旧版本的node.js,你应该安装node.js 4.0或更高版本。
请参考https://facebook.github.io/react-native/docs/getting-started.html
我正在使用node.js 5.0.0 – Obromios