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
相关推荐
上辈子杀猪这辈子学IT12 分钟前
【Zookeeper集群搭建】安装zookeeper、zookeeper集群配置、zookeeper启动与关闭、zookeeper的shell命令操作
linux·hadoop·zookeeper·centos·debian
minihuabei17 分钟前
linux centos 安装redis
linux·redis·centos
lldhsds1 小时前
书生大模型实战营第四期-入门岛-1. Linux前置基础
linux
wowocpp2 小时前
ubuntu 22.04 硬件配置 查看 显卡
linux·运维·ubuntu
山河君2 小时前
ubuntu使用DeepSpeech进行语音识别(包含交叉编译)
linux·ubuntu·语音识别
鹏大师运维2 小时前
【功能介绍】信创终端系统上各WPS版本的授权差异
linux·wps·授权·麒麟·国产操作系统·1024程序员节·统信uos
筱源源2 小时前
Elasticsearch-linux环境部署
linux·elasticsearch
pk_xz1234564 小时前
Shell 脚本中变量和字符串的入门介绍
linux·运维·服务器
小珑也要变强4 小时前
Linux之sed命令详解
linux·运维·服务器
Lary_Rock6 小时前
RK3576 LINUX RKNN SDK 测试
linux·运维·服务器