joewalnes / reconnecting-websocket

A small decorator for the JavaScript WebSocket API that automatically reconnects
MIT License
4.21k stars 970 forks source link

ReconnectingWebSocket is not defined, Electron app #94

Open ghost opened 6 years ago

ghost commented 6 years ago

Hi, I get an error while running an app in Electron. This app is running normally in browsers (firefox, chrome, chromium v63.0.3239.132), but not in Electron (chromium v58.0.3029.110)

Electron loads the url of the app in a browser window like a user would do and I get this error at launch:

ReconnectingWebSocket is not defined

Whatever I do (including the lib just before the implementation in the same file) I get this error.

jeeftor commented 6 years ago

Try import ReconnectingWebSocket from 'reconnecting-websocket'

yq5858588 commented 6 years ago

不行啊 我的也不行提示这个没有定义 我的跟他的是一样的 我们就是把普通的网页嵌入electron 正常网页是好的 但是嵌入后就不行了出错了 你上面说的方法是解决纯nodejs编写的应用的 我们的方式是用electron简单加载了我们的网页而已 所以你说的方法解决部了啊

UEhQZXI commented 5 years ago

Try this solution

<script>if (typeof module === 'object') {window.ReconnectingWebSocket = window.ReconnectingWebSocket = module.exports;};</script>