【发布时间】:2016-03-06 06:17:35
【问题描述】:
我是 React Native 的新手。我使用react-native init XXX 创建了一个新项目。启动 xcodeproj 时,我收到一条错误消息:
const setupEnvScript = /^win/.test(process.platform)
^^^^^
SyntaxError: Use of const in strict mode.
at Module._compile (module.js:439:25)
at Module._extensions..js (module.js:474:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/allanhahaha/Documents/Seat/getseat/SeatApp/node_modules/react-native/node_modules/babel-core/lib/api/register/node.js:214:7)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/allanhahaha/Documents/Seat/getseat/SeatApp/node_modules/react-native/cli.js:15:18)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
根据我的研究,这是一个 node.js 版本问题:我应该使用 v.4.0+。
我正在使用 NVM 来管理我的 node.js 版本。在常规终端窗口中,我有这个:
$ node --version
v5.1.0
但是在 xcode 中,当它运行启动 shell 脚本时,我看到它使用了不同的版本,v0.10.40,而 xcode 也不知道nvm 命令..
问题是,我应该如何配置我的 Mac,以便 xcode 可以选择我使用 nvm 设置的相同版本?
谢谢!
更新:我尝试在xcode执行的shell脚本中source我的~/.bash_profile,但还是没有解决问题。
【问题讨论】:
-
你看到这个问题了吗? github.com/facebook/react-native/issues/3974
-
嗨,Allan,你能告诉我们你的 bash_profile 中有什么,至少是关于 nvm 的部分吗?另外你通常使用 iTerm 还是终端?
-
@ColinRamsay 嗨,感谢您的评论,我刚刚尝试使用
. ~\.bash_profile,它成功了... -
@Almouro 谢谢你的评论,请看上面的回复
-
您可以将解决方案添加为下面的答案,然后自己接受以将此问题标记为已关闭。
标签: javascript node.js xcode react-native nvm