joewalnes / reconnecting-websocket

A small decorator for the JavaScript WebSocket API that automatically reconnects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ReconnectingWebSocket is not defined, Electron app

opened this issue · comments

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.

commented

Try
import ReconnectingWebSocket from 'reconnecting-websocket'

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

commented

Try this solution

<script src="./js/reconnecting-websocket.js"></script>

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