【问题标题】:Undefined is not a function - Evaluating require.getModules() || React native || inline require || Enable UnbundlingUndefined 不是函数 - 评估 require.getModules() ||反应原生 ||内联要求 ||启用解绑
【发布时间】:2019-02-16 15:02:27
【问题描述】:

我正在尝试解绑本机反应(内联要求),并且我想调查加载的模块。

react 原生版本 - ^0.49.3

关注官方文档https://facebook.github.io/react-native/docs/performance#investigating-the-loaded-modules

但它抛出一个错误 Undefined is not a function - 评估 require.getModules()

有人尝试过或遇到过类似的问题吗?

【问题讨论】:

  • 能否提供一些相关代码,可能有助于确定问题的原因。
  • @Dimitar facebook.github.io/react-native/docs/… 我在这里使用相同的代码 sn-p 提供
  • 谢谢。 console.log(require); 的输出是什么?
  • 您尝试的是发行版还是开发版?我的应用程序与gradlew assembleRelease 捆绑在一起时遇到了同样的问题,但它在开发模式下工作(使用react-native start)。 getModules() 是由 metro 填充的,由于某种原因,这个 polyfill 仅适用于开发模式。

标签: react-native require


【解决方案1】:

只需删除您添加的代码以创建用于在文件中预加载的模块名称

index.js or index.ios.js|index.android.js

然后重新构建

【讨论】:

  • 他特别提到他想运行那段代码。删除它不是一种选择。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-30
  • 2019-07-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多