Closed hugomd closed 4 years ago
Hi :wave:
Node isn't officially supported yet because we use XHR etc under the hood. We would like to officially support node at some point though so watch this space!
It's good to see that things seem to work with JSDOM! Thanks for the information on the workaround :)
Closing this as stale. Node support is in our internal backlog but it's not something that we're likely to pick up in the imminent future. Please contact support if this issue is important for your use case!
Hey 👋
First off, thanks for all the awesome work you do, Pusher is awesome 🚀
I've run into issues using this library on node (using v9.11.1) — just requiring it fails with errors like:
ReferenceError: window is not defined
``` /Users/hugo/git/pusher-relay-chat/client/node_modules/@pusher/chatkit/dist/web/chatkit.js:1 (function (exports, require, module, __filename, __dirname) { !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Chatkit=t()}(this,function(){"use strict";"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var e,t,n=(function(e,t){var n;n=function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=10)}([function(e,t,n){function r(e){var t={};if(!e)return t;for(var n=0,r=e.s ReferenceError: window is not defined at new e (/Users/hugo/git/pusher-relay-chat/client/node_modules/@pusher/chatkit/dist/web/chatkit.js:1:2031) at new e (/Users/hugo/git/pusher-relay-chat/client/node_modules/@pusher/chatkit/dist/web/chatkit.js:1:6764) at new e (/Users/hugo/git/pusher-relay-chat/client/node_modules/@pusher/chatkit/dist/web/chatkit.js:1:78367) at Object.Found this a little odd, given that the roll up config specifies the build for
umd
, but I'm not familiar with how roll up works 🤷♂️ https://github.com/pusher/chatkit-client-js/blob/3c6ee1fe05997782c803e8890ca8e405def77b60/rollup/web.js#L8I've managed to get around this using JSDOM to define a fake
window
andnavigator
global:Let me know if there's any other information I can provide 🙏