【问题标题】:promise – can't find variable process承诺 - 找不到变量过程
【发布时间】:2015-08-25 15:54:20
【问题描述】:

对于我的(第一个)react-native 项目,我使用 Node 模块 react-native-refreshable-listview 需要 CommonJS/A+ 承诺方法来显示指标。但是,每次消费者调用 promise 的 then 方法(例如 this.doSomething().then(function() { ... }))时,我都会收到以下错误:

Error: Can't find variable: process
 stack: 
  requestFlush                      index.ios.bundle:43767
  rawAsap                           index.ios.bundle:43709
  handle                            index.ios.bundle:43602
  finale                            index.ios.bundle:43661
  resolve                           index.ios.bundle:43651
  <unknown>                         index.ios.bundle:43683
  <unknown>                         index.ios.bundle:42446
  notifyAll                         index.ios.bundle:4880
  close                             index.ios.bundle:4597
  closeAll                          index.ios.bundle:6174
  perform                           index.ios.bundle:6115
  perform                           index.ios.bundle:4629
  flushBatchedUpdates               index.ios.bundle:4709
  ReactUpdates_flushBatchedUpdates  index.ios.bundle:4978
  closeAll                          index.ios.bundle:6174
  perform                           index.ios.bundle:6115
  batchedUpdates                    index.ios.bundle:13822
  batchedUpdates                    index.ios.bundle:4644
  <unknown>                         index.ios.bundle:7567
  applyWithErrorReporter            index.ios.bundle:7314
  guardReturn                       index.ios.bundle:7336
  processBatch                      index.ios.bundle:7566
 URL: http://192.168.16.250:8081/index.ios.bundle
 line: 43767
 message: Can't find variable: process

我已经阅读了this question,但我无法解决这个问题。 虽然 ControlledListView 组件可以用来规避这个错误,但我非常喜欢 promise 的概念,我打算在我的应用程序中使用更多。

我正在使用 react-native 版本 0.6.0 rc1 以及 iOS 8.3。

感谢您的帮助。提前致谢!

【问题讨论】:

  • 你在使用 Promise 库吗?哪一个?
  • 是的,我使用this website建议的库promiseNodeJS部分)

标签: javascript promise react-native es6-promise


【解决方案1】:

您正在尝试使用为 NodeJS 设计的 Promises 库,并且它正在尝试加载 React Native 中不可用的名为 process 的依赖项。

尝试另一个 promise 库,例如 Bluebird,因为它更可能与 React Native 一起使用;请参阅this issue,这表明它现在确实可以工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-01-10
    • 1970-01-01
    • 1970-01-01
    • 2020-07-21
    • 2016-12-25
    • 1970-01-01
    • 2016-09-18
    • 1970-01-01
    相关资源
    最近更新 更多