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
相关推荐
梅见十柒2 分钟前
wsl2中kali linux下的docker使用教程(教程总结)
linux·经验分享·docker·云原生
Koi慢热5 分钟前
路由基础(全)
linux·网络·网络协议·安全
传而习乎15 分钟前
Linux:CentOS 7 解压 7zip 压缩的文件
linux·运维·centos
我们的五年25 分钟前
【Linux课程学习】:进程程序替换,execl,execv,execlp,execvp,execve,execle,execvpe函数
linux·c++·学习
IT果果日记1 小时前
ubuntu 安装 conda
linux·ubuntu·conda
Python私教1 小时前
ubuntu搭建k8s环境详细教程
linux·ubuntu·kubernetes
羑悻的小杀马特1 小时前
环境变量简介
linux
小陈phd2 小时前
Vscode LinuxC++环境配置
linux·c++·vscode
是阿建吖!2 小时前
【Linux】进程状态
linux·运维
明明跟你说过2 小时前
Linux中的【tcpdump】:深入介绍与实战使用
linux·运维·测试工具·tcpdump