wscat 在安装时损坏

wscat 在安装时损坏

wscat 坏了 - 任何想法为什么 - 我经常使用这个工具,以前从未见过这个。

乌班图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'
  ]
}

答案1

下面的命令wscat为我带来了 Ubuntu 20.04 和 Ubuntu 22.04 中的工作工具:

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

然后我可以用它来调试 websocket 连接:

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

答案2

我能够通过进入来解决这个sudo npm install问题/usr/share/nodejs/wscat。不知道这是否是正确的方法。

相关内容