node-twitch
node-twitch copied to clipboard
TypeError: TwitchApi is not a constructor
running with a typescript application
"typescript": "^4.6.2"
import TwitchApi from 'node-twitch';
const twitch = new TwitchApi({
client_id: environment.TWITCH_AUTH.client_id,
client_secret: environment.TWITCH_AUTH.client_secret,
});
const user = await twitch.getUsers([name]);
I get this error when the method gets called
file:///F:/bot/src/commands/utility/twitch.command.ts:25 const twitch = new TwitchApi({ ^ TypeError: TwitchApi is not a constructor
Your import seems not correct, Have you tried to import it like that :
const TwitchApi = require('node-twitch').default;
I tried to reproduce it and the .default fixed it. Hope it helps. I wish you an excellent day