wscat 命令报错

使用wscat测试连接时报错:

[root@kafka kafka-logs]# wscat ws://xxx.xxx.com/bs
/usr/lib/node_modules/wscat/node_modules/commander/lib/command.js:921
  async parseAsync(argv, parseOptions) {
        ^^^^^^^^^^

SyntaxError: Unexpected identifier
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/lib/node_modules/wscat/node_modules/commander/index.js:2:21)

 

原因:nodejs版本过低

进行升级:

查看版本:

node -v

清楚npm缓存:

npm cache clean -f

安装n模块:

npm install -g n

升级:

#升级到指定版本
n v16.15.0
#升级到最新稳定版
n stable
#升级到最新版
n latest
#切换使用版本
n 16.15.0 (ENTIR)
#删除指定版本
n rm 16.15.0

 

posted @ 2022-05-13 16:36  心恩惠动  阅读(237)  评论(0编辑  收藏  举报