如何在电子中使用socket.io-client?

Jus*_*ung 8 socket.io electron

我正在尝试将socket.io-client添加到我的项目中.

我安装了 socket.io-client&@types/socket.io-client

但是当我尝试构建时,我遇到了这个错误:

/myproject/node_modules/webpack-target-electron-renderer/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js:37
TypeError: Cannot read property 'request' of undefined
Run Code Online (Sandbox Code Playgroud)

小智 0

node_modules 没有嵌入到 electro-builder 包中,解决方案是将所有模块导入到 index.js 入口点,如下所述: https: //www.electron.build/tutorials/loading-app-dependency-manually