Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Minor bug in the example from 'Inheriting from EventEmitter' section #285

Closed
ManasJayanth opened this issue Oct 26, 2015 · 1 comment
Closed

Comments

@ManasJayanth
Copy link

Inheriting from EventEmitter section requires events and incorrectly assigns to EventEmitter object.

const EventEmitter = require('events');

It should be

const EventEmitter = require('events').EventEmitter;

Even while introducing EventEmitter class, it mentions var EventEmitter = require('events'); which should have been var EventEmitter = require('events').EventEmitter;

Run the code otherwise complains TypeError: Object prototype may only be an Object or null, which is understandable as object returned by simply requiring events does not have prototype property.

@evanlucas
Copy link
Contributor

const EventEmitter = require('events') is actually the correct way of doing this now in v4.x

Refs: nodejs/node#3509

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants