FG
💻 Software📡 Networking

Cannot Resolve 'uws', Update README or "package.json"?

Fresh5 days ago
Mar 14, 20260 views
Confidence Score66%
66%

Problem

Note: for support questions, please use one of these channels: stackoverflow or slack You want to: [x] report a bug [ ] request a feature Current behaviour I downloaded the example project webpack-build-server from socket.io's master branch, run `npm install` to install the dependencies, and finally run `npm run build` to try to bundle the server, but webpack gives me the following errors: [code block]` Steps to reproduce (if the current behaviour is a bug) 1. Download socket.io's master branch 2. Go to `examples/webpack-build-server`; 3. Run `npm install`; 4. Run `npm run build`; Note: the best way to get a quick answer is to provide a failing test case, by forking the following fiddle for example. Expected behaviour A server.js file should be produced in `dist` folder. Setup - OS: macOS Hight SIerra - browser: Safari - socket.io version: 2.0.3 Other information (e.g. stacktraces, related issues, suggestions how to fix) These are what's printed in my terminal [code block]` Update I install `uws` package manually and it seems to work. Can someone update the README file or package.json since it's really hard for a beginner like me to figure this out.

Error Output

ERROR in ./~/engine.io/lib/server.js

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Add 'uws' Dependency to package.json and Update README

Low Risk

The error arises because the example project 'webpack-build-server' relies on the 'uws' (µWebSockets) package, which is not included in the package.json file. This omission leads to build failures when the server attempts to import 'uws' but cannot find it in the node_modules directory.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Add 'uws' to package.json

    Manually add 'uws' as a dependency in the package.json file to ensure it gets installed when running npm install.

    json
    {
      "dependencies": {
        "uws": "^0.14.5"
      }
    }
  2. 2

    Run npm install

    After updating package.json, run npm install to install the newly added 'uws' dependency.

    bash
    npm install
  3. 3

    Update README with Dependency Information

    Edit the README file to include instructions for installing 'uws' as a prerequisite for building the project. This will help future users avoid similar issues.

    markdown
    ## Prerequisites
    
    Before running the project, ensure you have the following dependencies installed:
    
    - uws: `npm install uws`
  4. 4

    Run Build Command

    Once 'uws' is installed, try building the project again to confirm that the issue is resolved.

    bash
    npm run build

Validation

To confirm the fix worked, ensure that the 'dist' folder contains the generated server.js file after running the build command. Additionally, verify that there are no errors related to 'uws' during the build process.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

socket.iowebsocketrealtime