question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Can't resolve 'uws'

See original GitHub issue

Note: 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)

  1. Add socket.io v2.2.0 to your existing project (which uses webpack) as a production dependency.
  2. Require it in your entry point code.
  3. 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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
Domiiicommented, Jan 24, 2020

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 default wsEngine. So unless you actually want to use uws, you don’t have to worry about it at all because engine.io won’t even require it in that case.

However, webpack does not know that. It only sees the dependency in the code, it sees require('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 your externals in your webpack.config and you are done 😃

E.g.:

module.exports = {
  // ...
  externals: { 
     uws: 'uws' 
  }
};
5reactions
mmdevriescommented, Aug 28, 2019

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found