node-onesignal
node-onesignal copied to clipboard
TypeError: OneSignalClient is not a constructor
> root@ip-172-31-41-200:/usr/share/nginx/html/webapps/node_modules/node-onesignal/dist# node
> var OneSignalClient = require('node-onesignal');
undefined
> var client = new OneSignalClient('1', '2');
TypeError: OneSignalClient is not a constructor
at repl:1:14
at ContextifyScript.Script.runInThisContext (vm.js:23:33)
at REPLServer.defaultEval (repl.js:339:29)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.onLine (repl.js:536:10)
at emitOne (events.js:101:20)
at REPLServer.emit (events.js:191:7)
at REPLServer.Interface._onLine (readline.js:241:10)
at REPLServer.Interface._line (readline.js:590:8)
>
Node version is
# node --version
v7.10.0
#
Any idea how to fix this error ?
EDIT: i tried on v8.0.0, got same error
Same issue here
I got it fixed by using
const OneSignalClient = require('node-onesignal').default;
I believe this has something to do with the Babel transpilation and Node 7/8. I'll try to look at this sometime soon and resolve it.
Thanks for reporting!
Thanks @HostOnNet and @jamesdixon. @HostOnNet, your workaround worked beautifully. Thank you.