我是个新来的本地人.我用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版本.在regular terminal window中,我有这样一个:

$ node --version
v5.1.0

但在xcode中,当它运行start shell脚本时,我看到它使用的是另一个版本v0.10.40,xcode也不知道nvm命令..

The question is, how should I configure my Mac so the xcode can pick up the same version that I set with nvm?

非常感谢.


Update:我试图在xcode执行的shell脚本中输入我的~/.bash_profile,但仍然没有解决问题.

推荐答案

我通过在shell脚本顶部添加. ~\.bash_profile解决了这个问题.

React-native相关问答推荐

ITMS—91053:缺少API声明—ReactNative

一旦我关闭应用程序,Json struct 就会发生变化

React Native - 如何在从另一个屏幕导航后将 ScrollView 滚动到给定位置

在 TouchableOpacity 上创建 Raised凸起或Shadow阴影效果

Eslint 错误,configuration for rule "import/no-cycle" is invalid

我可以在状态内有一个函数来响应吗?

使用 React-Native 将 content:// URI 转换为 Android 的实际路径

React中类似于 React Native 中的 FlatList

React Native 入门元素Bundle 失败,出现 Unexpected Token 错误

React Navigation 5 隐藏Drawer抽屉元素

React-Native:save user preferences

从组件的 style属性中获取 CSS 属性值

如何在react native应用程序名称中添加空格?

react-native android应用程序中的underlineColorAndroid is not a valid style property错误

在 React Native 视图上强制 onLayout

react-native Bottom Up drawer

键盘上方的 React Native 完成按钮

React Native:如何将 的高度和宽度设置为 容器?

如何在react-native中关闭模态

无法运行 jetifier React Native