wscat

wscat 是一个用于 WebSocket 通信测试的命令行工具

安装wscat

复制代码
flynnsin@flynnsin:~$ sudo npm install -g wscat
loadDep:ws → afterAdd     ▄ ╢████████████████████████████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
npm ERR! Linux 5.4.0-150-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "wscat"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code EMISSINGARG

npm ERR! typeerror Error: Missing required argument #1
npm ERR! typeerror     at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)
npm ERR! typeerror     at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)
npm ERR! typeerror     at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)
npm ERR! typeerror     at /usr/share/npm/lib/install/deps.js:457:7
npm ERR! typeerror     at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror     at /usr/share/npm/lib/fetch-package-metadata.js:37:12
npm ERR! typeerror     at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5)
npm ERR! typeerror     at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7)
npm ERR! typeerror     at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20)
npm ERR! typeerror     at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror This is an error with npm itself. Please report this error at:
npm ERR! typeerror     <http://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /home/flynnsin/npm-debug.log

安装nvm

复制代码
sudo curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 15037  100 15037    0     0  10634      0  0:00:01  0:00:01 --:--:-- 10634
=> nvm is already installed in /home/flynnsin/.nvm, trying to update using git
=>   master

* (头指针分离于 FETCH_HEAD)
  => Compressing and cleaning up git repository

=> Appending nvm source string to /home/flynnsin/.bashrc
=> Appending bash_completion source string to /home/flynnsin/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
flynnsin@flynnsin:~/tool$ 

安装新版

复制代码
export NVM_DIR="$HOME/.nvm"
flynnsin@flynnsin:~/tool$ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # 这将加载 nvm
flynnsin@flynnsin:~/tool$ [ -s "$NVM_DIR/bash_completion" ] &&\. "$NVM_DIR/bash_completion" # 这将加载 nvm bash_completion
flynnsin@flynnsin:~/tool$ nvm current
system
flynnsin@flynnsin:~/tool$ nvm install --lts
Installing latest LTS version.
Downloading and installing node v20.9.0...
Downloading https://nodejs.org/dist/v20.9.0/node-v20.9.0-linux-x64.tar.xz...
############################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v20.9.0 (npm v)
Creating default alias: default -> lts/* (-> v20.9.0)

新版不支持

复制代码
flynnsin@flynnsin:~/tool$ node -v
node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node)
flynnsin@flynnsin:~/tool$ sudo npm install -g wscat
sudo: npm:找不到命令
flynnsin@flynnsin:~/tool$ npm install -g wscat
node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node)
flynnsin@flynnsin:~/tool$ nvm ls-remote

安装稳定版

复制代码
flynnsin@flynnsin:~/tool$ nvm install lts/erbium
Downloading and installing node v12.22.12...
Downloading https://nodejs.org/dist/v12.22.12/node-v12.22.12-linux-x64.tar.xz...
############################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v12.22.12 (npm v6.14.16)
flynnsin@flynnsin:~/tool$ nvm use lts/erbium
Now using node v12.22.12 (npm v6.14.16)
flynnsin@flynnsin:~/tool$ node -v
v12.22.12
flynnsin@flynnsin:~/tool$ npm install -g wscat
/home/flynnsin/.nvm/versions/node/v12.22.12/bin/wscat -> /home/flynnsin/.nvm/versions/node/v12.22.12/lib/node_modules/wscat/bin/wscat
+ wscat@5.2.0
added 9 packages from 7 contributors in 4.749s
flynnsin@flynnsin:~/tool$ wscat ^C

只能一个终端使用 node,修改默认

复制代码
nvm ls
      v12.22.12
        v20.9.0
         system
default -> lts/* (-> v20.9.0)

怎么更改这个 default版本
ChatGPT
要更改 nvm 的默认 Node.js 版本,您可以使用以下命令:

bash
Copy code
nvm alias default [新Node.js版本号]

记得退出终端

flynnsin@flynnsin:~/tool$ node -v
v12.22.12
相关推荐
java叶新东老师14 分钟前
linux 部署 flink 1.15.1 并提交作业
linux·运维·flink
程序员JerrySUN1 小时前
Linux系统架构核心全景详解
linux·运维·系统架构
无敌的牛1 小时前
Linux文件理解,基础IO理解
linux·运维·服务器
未来之窗软件服务1 小时前
跨平台 WebSocket 服务器的设计与实现 —— 基于.NET 8 的跨操作系统解决方案linux,macos,windows——开发工具
linux·服务器·websocket·仙盟创梦ide·东方仙盟
杰哥的狗2 小时前
nacos连接失败,启动失败常见问题
linux·docker
Jackilina_Stone2 小时前
【faiss】用于高效相似性搜索和聚类的C++库 | 源码详解与编译安装
android·linux·c++·编译·faiss
XXYBMOOO2 小时前
Xilinx-FPGA-PCIe-XDMA 驱动内核兼容性问题修复方案
linux·运维·服务器
爱学习的狮王3 小时前
window10和ubuntu22.04双系统之卸载ubuntu系统
linux·运维·ubuntu
DIY全栈开发3 小时前
ESP32S3 Ubuntu vscode如何使用USB-JTAG调试
linux·vscode·ubuntu
努力自学的小夏3 小时前
RK3568 Linux驱动学习——Linux驱动开发准备工作
linux·驱动开发·笔记·学习