TheThingsArchive / node-app-sdk

The Things Network Application SDK for Node.JS
https://www.thethingsnetwork.org/docs/node-js/
MIT License
41 stars 28 forks source link

EventEmitter not a function #56

Closed JonasSaegesser closed 7 years ago

JonasSaegesser commented 7 years ago

Hello Everyone

I installed the latest ttn packacke with npm. When I tried to launch your sample app I got the following error: .../node_modules/ttn/dist/client.js:19 this.ee = new EventEmitter(); ^ TypeError: object is not a function

I checked client.js and found the following line: var EventEmitter = require('events');

I changed it to var EventEmitter = require('events').EventEmitter;

and now it is fine. I am not sure why this was working for other users. But I think this should be the right way.

Cheers Jonas

johanstokking commented 7 years ago

What is your Node version? node -v

A pull request is appreciated!

johanstokking commented 7 years ago

It doesn't seem to be necessary, right? https://nodejs.org/api/events.html

JonasSaegesser commented 7 years ago

I was running an ancient version of node. Sorry about that. Strange that I got that version from the Amazon Linux default package repo.