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
相关推荐
冬天vs不冷19 分钟前
Linux用户与权限管理详解
linux·运维·chrome
凯子坚持 c1 小时前
深入Linux权限体系:守护系统安全的第一道防线
linux·运维·系统安全
✿ ༺ ོIT技术༻1 小时前
C++11:新特性&右值引用&移动语义
linux·数据结构·c++
watermelonoops4 小时前
Deepin和Windows传文件(Xftp,WinSCP)
linux·ssh·deepin·winscp·xftp
疯狂飙车的蜗牛5 小时前
从零玩转CanMV-K230(4)-小核Linux驱动开发参考
linux·运维·驱动开发
远游客07137 小时前
centos stream 8下载安装遇到的坑
linux·服务器·centos
马甲是掉不了一点的<.<7 小时前
本地电脑使用命令行上传文件至远程服务器
linux·scp·cmd·远程文件上传
jingyu飞鸟7 小时前
centos-stream9系统安装docker
linux·docker·centos
超爱吃士力架8 小时前
邀请逻辑
java·linux·后端
cominglately10 小时前
centos单机部署seata
linux·运维·centos