为什么我无法在 React Native 中捕获导入错误?

Jor*_*dge 5 commonjs sjcl react-native

这段代码在 React Native 中失败,但在 Node 中没有:

try {
  return require('module-does-not-exist');
}catch (e) {
  return null;
}
Run Code Online (Sandbox Code Playgroud)

谁能告诉我为什么?

我为什么关心:

我正在尝试在我的 React Native 应用程序中使用斯坦福 JavaScript 加密库,但它在导入时失败,因为它使用此模式来选择使用crypto内置节点。(源代码

似乎其他人之前也遇到过这个问题:https : //github.com/davidbau/seedrandom/pull/44