2
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 搜索过,但没有人适合我。

socket.io-client@0.9.7 是旧版本,无法更新。因为服务器中的socket.io版本是0.9.7,不能改。如果我更新客户端将不会连接服务器。

4

1 回答 1

5

我遇到了同样的问题,并找到了下一个解决方案——替换需要 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
于 2016-12-23T09:44:05.317 回答