alxhotel / chromecast-api

:tv: Chromecast Node.js module
MIT License
155 stars 49 forks source link

TypeError: ChromecastAPI is not a constructor #89

Closed memecode closed 3 months ago

memecode commented 3 months ago

I started getting this error when I updated node to v20.16.0 and also chromecast-api@0.2.6

Using this code...

const ChromecastAPI = require('chromecast-api') chromecastClient = new ChromecastAPI();

Results in:

TypeError: ChromecastAPI is not a constructor at castBrowse (/var/www/html/node/indexer.js:1849:28) at WebSocket. (/var/www/html/node/indexer.js:2247:17) at WebSocket.emit (node:events:519:28) at Receiver.receiverOnMessage (/var/www/html/node/node_modules/ws/lib/websocket.js:1070:20) at Receiver.emit (node:events:519:28)

Is there a work around or fix for this?

memecode commented 3 months ago

Ugh, so npm downgraded my chromecast-api version for some reason. By setting my package.json dependency to "chromecast-api": "^0.4.2" and then running npm update it sorted itself out.

Leaving this here for google to index in case someone else has this issue.