Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Socket.io: Module not found: Can't resolve 'uws' in 'C\:....\node_modules\engine.io\lib'

I'm trying to use socket.io for my react/flask project and every time I require socket.io in my app.js file, node fails to compile and I get this message.

Failed to compile.

./node_modules/engine.io/lib/server.js

Module not found: Can't resolve 'uws' in 'C:\Users\Walker\Desktop\xxxxx\xxxxx\node_modules\engine.io\lib'

I've tried manually installing uws with node, but nothing changes. I also used create-react-app on another computer and installed socket.io but I'm getting the same error. I followed many 'Getting Started' articles but I'm continuously getting the same error. Anyone know what could be wrong?

like image 850
Walker Reynolds Avatar asked Oct 02 '18 21:10

Walker Reynolds


People also ask

What is Socket.IO error?

Error − An error event is sent from the server. Message − When the server sends a message using the send function. Reconnect − When reconnection to the server is successful. Reconnecting − When the client is in the process of connecting.


1 Answers

Try using socket.io-client

Here is the code:

import openSocket from 'socket.io-client';

const socket = openSocket(myURL);
like image 73
Matt Kuhns Avatar answered Oct 28 '22 11:10

Matt Kuhns