gpt4 book ai didi

typescript - socket.io-client@0.9.7 带有 typescript 和 webpack2 导入错误

转载 作者:行者123 更新时间:2023-12-02 04:03:45 27 4
gpt4 key购买 nike

ERROR in ./~/socket.io-client/bin/builder.js
Module not found: Error: Can't resolve 'fs' in 'E:\work\brickman2\node_modules\socket.io-client\bin'
@ ./~/socket.io-client/bin/builder.js 11:9-22
@ ./~/socket.io-client/lib/io.js
@ ./src/services/pusher.ts
@ multi main

ERROR in ./~/xmlhttprequest/lib/XMLHttpRequest.js
Module not found: Error: Can't resolve 'fs' in 'E:\work\brickman2\node_modules\xmlhttprequest\lib'
@ ./~/xmlhttprequest/lib/XMLHttpRequest.js 16:9-22
@ ./~/socket.io-client/lib/util.js
@ ./~/socket.io-client/lib/io.js
@ ./src/services/pusher.ts
@ multi main

ERROR in ./~/xmlhttprequest/lib/XMLHttpRequest.js
Module not found: Error: Can't resolve 'child_process' in 'E:\work\brickman2\node_modules\xmlhttprequest\lib'
@ ./~/xmlhttprequest/lib/XMLHttpRequest.js 15:12-36
@ ./~/socket.io-client/lib/util.js
@ ./~/socket.io-client/lib/io.js
@ ./src/services/pusher.ts
@ multi main

我通过 google 和 github issus 进行了搜索,但没有人为我工作。

[email protected]是旧版本,但无法更新。因为服务器中的socket.io版本是0.9.7并且无法更改。如果我更新客户端将无法连接服务器。

最佳答案

我遇到了同样的问题,并找到了下一个解决方案 - 将其捆绑版本替换为需要 socket-io.client。

ES5版本

//var io = require('socket.io-client');
var io = require('socket.io-client/dist/socket.io.js'); //worked solution

ES6版本

//import io from 'socket.io-client';
import io from 'socket.io-client/dist/socket.io.js'; //worked solution

关于typescript - socket.io-client@0.9.7 带有 typescript 和 webpack2 导入错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40500964/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com