如何使ReactNative堆栈跟踪/错误消息更具可读性

时间:2016-12-14 04:58:32

标签: react-native

我尝试使用ReactNative测试开发,然后我尝试在<br/>组件中添加<Text>(因为它是一个无效的组件),它显示如下:

TypeError: Cannot read property 'Symbol(Symbol.iterator)' of null
at launchEditor (/Users/user/Documents/AwesomeProject/node_modules/react-native/local-cli/server/util/launchEditor.js:153:29)
at Object.handle (/Users/user/Documents/AwesomeProject/node_modules/react-native/local-cli/server/middleware/openStackFrameInEditorMiddleware.js:17:7)
at next (/Users/user/Documents/AwesomeProject/node_modules/connect/lib/proto.js:174:15)
at Object.handle (/Users/user/Documents/AwesomeProject/node_modules/react-native/local-cli/server/middleware/getDevToolsMiddleware.js:74:7)
at next (/Users/user/Documents/AwesomeProject/node_modules/connect/lib/proto.js:174:15)
at Object.handle (/Users/user/Documents/AwesomeProject/node_modules/react-native/local-cli/server/middleware/getDevToolsMiddleware.js:74:7)
at next (/Users/user/Documents/AwesomeProject/node_modules/connect/lib/proto.js:174:15)
at Object.compression [as handle] (/Users/user/Documents/AwesomeProject/node_modules/compression/index.js:205:5)
at next (/Users/user/Documents/AwesomeProject/node_modules/connect/lib/proto.js:174:15)
at IncomingMessage.<anonymous> (/Users/user/Documents/AwesomeProject/node_modules/react-native/local-cli/server/middleware/loadRawBodyMiddleware.js:20:5)

在设备上:

screenshot

有没有办法让你更容易阅读错误(哪一行是问题)?

1 个答案:

答案 0 :(得分:0)

您应该定义REACT_EDITOR环境变量以允许RN运行您喜欢的文本编辑器。最简单的方法是运行env REACT_EDITOR=atom npm start之类的东西。或者您可以永久设置此变量,只需google how to set environment variable on ${OS}