我正在使用 PM2 版本 5.1.2,该应用程序处于集群模式。收到此错误,并且 pm2 不断重新启动并出现相同的错误。
好像和集群模式有关系,但没找到解决办法。
PM2 | ===============================================================================
PM2 | --- PM2 global error caught ---------------------------------------------------
PM2 | Time : Tue Dec 21 2021 13:45:52 GMT+0000 (Coordinated Universal Time)
PM2 | type.slice is not a function
PM2 | TypeError: type.slice is not a function
PM2 | at EventEmitter.emit (/usr/lib/node_modules/pm2/node_modules/eventemitter2/lib/eventemitter2.js:343:77)
PM2 | at Worker.cluMessage (/usr/lib/node_modules/pm2/lib/God/ClusterMode.js:65:24)
PM2 | at Worker.emit (events.js:412:35)
PM2 | at Worker.emit (domain.js:537:15)
PM2 | at ChildProcess.<anonymous> (internal/cluster/worker.js:33:12)
PM2 | at ChildProcess.emit (events.js:400:28)
PM2 | at ChildProcess.emit (domain.js:537:15)
PM2 | at emit (internal/child_process.js:912:12)
PM2 | at processTicksAndRejections (internal/process/task_queues.js:83:21)
PM2 | ===============================================================================
PM2 | [PM2] Resurrecting PM2
PM2配置:
--- Daemon -------------------------------------------------
pm2d version : 5.1.2
node version : 14.18.2
node path : /usr/bin/pm2
argv : /usr/bin/node,/usr/lib/node_modules/pm2/lib/Daemon.js
argv0 : node
user : marcos
uid : 1001
gid : 1002
uptime : 0min
===============================================================================
--- CLI ----------------------------------------------------
local pm2 : 5.1.2
node version : 14.18.2
node path : /usr/bin/pm2
argv : /usr/bin/node,/usr/bin/pm2,report
argv0 : node
user : marcos
uid : 1001
gid : 1002
===============================================================================
--- System info --------------------------------------------
arch : x64
platform : linux
type : Linux
cpus : Intel(R) Xeon(R) CPU @ 2.20GHz
cpus nb : 2
freemem : 6384754688
totalmem : 8340885504
home : /home/marcos
===============================================================================
当全局安装的包或包版本与本地安装的包不匹配时,就会出现此错误。就我而言,我已全局安装了 @socket.io/pm2 软件包,但 pm2 是本地安装的。