How to Require Node Event Module in React Native

How do I need a events

Node module in my React Native project? I ran into some module dependency issues with util

and http

which I resolved with Browserify for packaging.

I am trying to use the same approach with events

:

npm install events var EventEmitter = require('events').EventEmitter;

After packaging with Browserify, I still get the same error from React Native: "Unknown module required". "

+3


source to share


2 answers


This is what you want: https://github.com/facebook/react-native/issues/1058



var EventEmitter = require ('EventEmitter');

+2


source


I am using events and a bunch of other core node modules using react-native-webpack-server . It requires a bit of tweaking, but otherwise you run into the same issue with Buffer, assert, util, crypto, etc. Better take care of all of them in one go.



0


source







All Articles