如何在 React Native 中要求节点事件模块 [英] How to require Node Events module in React Native
本文介绍了如何在 React Native 中要求节点事件模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在我的 React Native 项目中要求 events
Node 模块?我在使用 util
和 http
时遇到了一些模块依赖问题,我通过使用 Browserify 打包解决了这些问题.
How do I require the events
Node module within my React Native project? I ran into some module dependency issues with util
and http
which I resolved by using Browserify to package.
我尝试对 events
采取相同的方法:
I try to take the same approach with events
:
npm install events
var EventEmitter = require('events').EventEmitter;
使用 Browserify 打包后,我仍然收到来自 React Native 的相同错误:Requiring unknown module 'events'."
After packaging with Browserify, I still get the same error from React Native: "Requiring unknown module 'events'."
推荐答案
这就是你想要的:https://github.com/facebook/react-native/issues/1058
var EventEmitter = require('EventEmitter');
这篇关于如何在 React Native 中要求节点事件模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文