You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.
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.<anonymous> (/Users/hugo/git/pusher-relay-chat/client/index.js:25:21)
at Module._compile (internal/modules/cjs/loader.js:654:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)
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 π€·ββοΈ
I've managed to get around this using JSDOM to define a fake window and navigator global:
const{JSDOM}=require('jsdom');const{ChatManager, TokenProvider}=require('@pusher/chatkit');// Hack so that @pusher/chatkit can be usedconst{window}=newJSDOM();global.window=window;global.navigator={};constchatManager=newChatManager({
instanceLocator,
userId,tokenProvider: newTokenProvider({url: 'http://localhost:3000/auth'}),});
Let me know if there's any other information I can provide π
The text was updated successfully, but these errors were encountered:
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
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 π€·ββοΈchatkit-client-js/rollup/web.js
Line 8 in 3c6ee1f
I'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 π
The text was updated successfully, but these errors were encountered: