2

wscat broken - any ideas why - I use this tool a lot, never seen this before.

Ubuntu 20.04

# npm install -g wscat

added 9 packages in 2s

root@simp:~# wscat 
node:internal/modules/cjs/loader:988
  throw err;
  ^

Error: Cannot find module 'debug'
Require stack:
- /usr/lib/x86_64-linux-gnu/nodejs/ws/node_modules/https-proxy-agent/index.js
- /usr/lib/x86_64-linux-gnu/nodejs/wscat/bin/wscat
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
    at Function.Module._load (node:internal/modules/cjs/loader:833:27)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/usr/lib/x86_64-linux-gnu/nodejs/ws/node_modules/https-proxy-agent/index.js:11:13)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Module.require (node:internal/modules/cjs/loader:1057:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/lib/x86_64-linux-gnu/nodejs/ws/node_modules/https-proxy-agent/index.js',
    '/usr/lib/x86_64-linux-gnu/nodejs/wscat/bin/wscat'
  ]
}

2 Answers 2

1

The command below brings working wscat tool in both Ubuntu 20.04 and Ubuntu 22.04 for me:

apt-get update && apt-get install -y --no-install-recommends ca-certificates node-ws

And then I could use it to debug websocket connections:

> wscat -c "wss://example.com/ws"
Connected (press CTRL+C to quit)
< 4
< {response from example.com}
0

I was able to fix this by going sudo npm install in /usr/share/nodejs/wscat. No idea if that is the correct approach.

1
  • Welcome to the site, and thank you for your contribution. However, given that you yourself are unsure why your approach works, your post may be better placed as a comment unter the question rather than a full-fledged answer.
    – AdminBee
    Mar 30, 2023 at 9:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .