React Native-调试异常 [英] React Native - debugging exception

查看:118
本文介绍了React Native-调试异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用chrome调试本机响应. 当我在源"调试选项卡下选择暂停捕获的异常"时,始终会发生以下异常:TypeError: freeProcess.binding is not a function

I'm using chrome to debug react native. When I choose "Pause On Caught Exceptions" under "source" debugging tab, the following exception always occur: TypeError: freeProcess.binding is not a function

发生异常的文件:

http://localhost:8081/< Project_folder >/node_modules/react-proxy/node_modules/lodash/_nodeUtil.js

第18行是例外: return freeProcess && freeProcess.binding('util');

该.js页面上的完整代码:

Full code on that .js page:

var freeGlobal = require('./_freeGlobal');

/** Detect free variable `exports`. */
var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;

/** Detect free variable `module`. */
var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;

/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports = freeModule && freeModule.exports === freeExports;

/** Detect free variable `process` from Node.js. */
var freeProcess = moduleExports && freeGlobal.process;

/** Used to access faster Node.js helpers. */
var nodeUtil = (function() {
  try {
    return freeProcess && freeProcess.binding('util');
  } catch (e) {}
}());

module.exports = nodeUtil;

避免这种异常的最优雅方法是什么?

What is the most elegant way to avoid this exception?

谢谢!

推荐答案

好,所以我暂时解决了该问题.

Ok, so I've solved it temporarily.

我将第18行更改为:

return freeProcess && (typeof freeProcess.binding === "function") && freeProcess.binding('util');

在此文件中:

/< Project_folder >/node_modules/react-proxy/node_modules/lodash/_nodeUtil.js

此解决方案不是最佳解决方案,因为它应该在库的git中修复.我认为该库是lodash的,但是我无法在其git中找到该文件- https://github.com /lodash/lodash

This solution is not the best, because it should be fixed in the git of the library. I think the library is lodash, but I couldn't find the file in its git - https://github.com/lodash/lodash

这篇关于React Native-调试异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆