I'm experimenting with r-node, a package that relies on Node js. The package itself is a bit outdated, relying on node_events, an old file from the mid 2010s. At the build stage, it complains of the following:
src/binding.cc:24:10: fatal error: 'node_events.h' file not found
#include <node_events.h>
^
1 error generated.
make[1]: *** [src/binding.o] Error 1
make: *** [server] Error 2
node_events was removed from Node js circa 2 years ago: https://github.com/joyent/node/commit/4ef8f06fe62edb74fded0e817266cb6398e69f36#src/node_events.h
I'm wondering what the background is--why did the node js folks remove this particular file, and how would package writers update their end to keep up with this. Thanks.
As much as I understand node.js source code when it existed node_events.{h,cc} the platform used an emitter writed in C :
var EventEmitter = exports.EventEmitter = process.EventEmitter
But they realised that it would be much better to create an event emitter directly from javascript code:
var EventEmitter = NativeModule.require('events').EventEmitter;
lib/events.js:
function EventEmitter() {
this.domain = null;
if (exports.usingDomains) {
// if there is an active domain, then attach to it.
domain = domain || require('domain');
if (domain.active && !(this instanceof domain.Domain)) {
this.domain = domain.active;
}
}
this._events = this._events || null;
this._maxListeners = this._maxListeners || defaultMaxListeners;
}
exports.EventEmitter = EventEmitter;
So if you are using a package that uses the old event emitter just delete the inclusion #include <node_events.h>(with all deps) from the sources that you want to update and recompile again.