question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

self.on is not a function

See original GitHub issue

Code I try to run:

var HID = require('node-hid');
var device = HID.HID(21324, 1);

The resulting error:

        self.on("newListener", function(eventName, listener) {
             ^

TypeError: self.on is not a function
    at Object.HID (/home/peepee/dev/trezor-connection/node_modules/node-hid/nodehid.js:48:7)
    at Object.<anonymous> (/home/peepee/dev/trezor-connection/lib/index.js:43:18)
    at Module._compile (module.js:399:26)
    at Object.Module._extensions..js (module.js:406:10)
    at Module.load (module.js:345:32)
    at Function.Module._load (module.js:302:12)
    at Function.Module.runMain (module.js:431:10)
    at startup (node.js:141:18)
    at node.js:977:3

When I digged deeper, it seems the HID never inherits eventemitter correctly. I am not sure why.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
karelbilekcommented, Jul 15, 2016

Oh. That’s because I call

var foo = HID.HID(21324, 1)

the correct call is

var foo = new HID.HID(21324, 1)

That’s about it.

0reactions
todbotcommented, Jul 17, 2016

I don’t think so. I’ll close this issue anyway, if you find out anything, please update enhancement issue #150. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I get around the error TypeError: self._form.on is not a ...
It seems the reason that this occurs is that when handling an error, the request module uses the .on method on a FormData...
Read more >
TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >
How to Handle JavaScript Uncaught TypeError: “x” is Not a ...
The Javascript TypeError: "x" is not a function occurs when calling a function on a value or object, which is not actually a...
Read more >
JavaScript Function Definitions - W3Schools
Function expressions can be made "self-invoking". A self-invoking expression is invoked (started) automatically, without being called. Function expressions will ...
Read more >
self in Python, Demystified - Programiz
This is the reason the first parameter of a function in class must be the object itself. Writing this parameter as self is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found