javascript - 如何忽略 React Native 中的导入失败?

标签 javascript android node.js react-native import

我想在 React Native 的脚本中导入模块。该模块只有 index.android.js,因此在 iOS 上导入会失败。 既然我在 iOS 中不需要该模块,我怎样才能忽略它呢?

我尝试使用 if (Platform.OS == 'android') Module = require('module') 但它仍然抛出 UnableToResolveError:

Module does not exist in the module map or in these directories: D:\myproject\node_modules

重要: 我不想修改模块。

最佳答案

你可以尝试利用这个https://github.com/facebook/react-native/issues/7271这不是完整的答案,但可以帮助您。

关于javascript - 如何忽略 React Native 中的导入失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50836012/

相关文章:

javascript - 具有嵌套 ajax 调用的 jQuery 延迟对象

node.js - 向REDIS中插入数据(node.js + redis)

javascript - 在函数签名中使用 TypeScript 类型的对象值

javascript - 站点地图的子菜单隐藏在 Asp.net 页面中的 JavaScript 图片库后面?

javascript - 在nodejs中导入MySQL数据库进行集成测试的最简单方法

javascript - jQuery 单击单击事件不适用于数据表

android - 将标签值设置为图像按钮

android - 如何让View填充ConstraintLayout中的剩余空间

android - 如何在 Android 上使用 Polaris Viewer 创建打开 .doc 文件的 Intent ?

node.js - 无法确定 Architect 命令 Angular 的项目或目标