Error: Can't resolve 'uws'
See original GitHub issueNote: for support questions, please use one of these channels: stackoverflow or slack
You want to:
- report a bug
- request a feature
Current behaviour
I use socket.io, therefore engine.io is one of my depended packages.
When I try to bundle my project, I have error
Module not found: Error: Can’t resolve ‘uws’ in node_modules/engine.io/lib/server.js
(The error would not be here if I configure webpack with webpack-node-externals
, but I really need all packages in a single bundle for docker container.)
Steps to reproduce (if the current behaviour is a bug)
- Add socket.io v2.2.0 to your existing project (which uses webpack) as a production dependency.
- Require it in your entry point code.
- Run webpack
Expected behaviour
It should create a bundle without errors.
Setup
- OS: centOS
- browser: server side (node.js)
- engine.io version: 3.3.2
Other information (e.g. stacktraces, related issues, suggestions how to fix)
IMO it could be fixed if engine.io declares uws as a prod dependency (not a dev dependency).
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Can't resolve 'uws' in 'C:\....\node_modules\engine.io\lib · Issue ...
If tried to manually install uws and ws but I get the same behavior. Steps to reproduce (if the current behaviour is a...
Read more >node.js - Socket.io: Module not found: Can't resolve 'uws' in 'C
So I just had this same issue, but for a very different reason. Currently when I install the latest socket.io server package from...
Read more >Error: Cannot find module [Solved] - Glitch Support
It looks like a bug in the aq3d module. It's referencing a directory called Dungeon , which is actually named dungeon . If...
Read more >UWS & Internet Access - University of Alberta
From wireless access available campus-wide to remote access through our Virtual Private Network services, we'll make sure you stay connected.
Read more >eiows - npm
Keywords. websocket · engine.io · socket.io · eiows · uws. Install. npm i eiows. Repository. github.com/mmdevries/eiows. Homepage.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you are here because your
webpack
build fails - good news: There is an easy fix!Problem Explanation
In recent
socket.io
versions,ws
is already set as the defaultwsEngine
. So unless you actually want to useuws
, you don’t have to worry about it at all becauseengine.io
won’t evenrequire
it in that case.However,
webpack
does not know that. It only sees the dependency in the code, it seesrequire('uws')
, and, not knowing that that part of the code will never execute, it will try to bundle it nevertheless.Solution
Simply tell it to not bundle it by adding
uws
to yourexternals
in yourwebpack.config
and you are done 😃E.g.:
@sethcwhiting unfortunately this version doesn’t work with node 10 and higher. At least if you want to use a secure connection(wss). We didn’t want to step over to the javascript ws package and we created a new uws package and added support for node 10 and node 12. This new package is based on the original uws and we merged some fixes from cws. Maybe this will be useful for others as well.
https://github.com/mmdevries/uws