谢谢你点击这个问题。我试图在没有外部库的情况下重新启动nodeJS进程。我做了这个代码:
function restartProcess() {
spawn(process.argv[1], process.argv.slice(2), {
detached: true,
stdio: ['ignore', out, err]
}).unref()
process.exit()
}
bot.on( "kicked", (reason) => {
console.log("KICKED! "+ reason)
restartProcess()
})但是,当调用restartProcess()时,我会得到错误:
C:\Users\Toshiba\Desktop\program\mineflayer\spbot\bot.js:7
stdio: ['ignore', out, err]
^
ReferenceError: out is not defined
at restartProcess (C:\Users\Toshiba\Desktop\program\mineflayer\spbot\bot.js:7:25)
at EventEmitter.<anonymous> (bot.js:54:5)
at EventEmitter.emit (events.js:315:20)
at Client.<anonymous> (C:\Users\Toshiba\node_modules\mineflayer\lib\plugins\kick.js:5:9)
at Client.emit (events.js:315:20)
at FullPacketParser.<anonymous> (C:\Users\Toshiba\node_modules\minecraft-protocol\src\client.js:89:12)
at FullPacketParser.emit (events.js:315:20)
at addChunk (C:\Users\Toshiba\node_modules\readable-stream\lib\_stream_readable.js:298:12)
at readableAddChunk (C:\Users\Toshiba\node_modules\readable-stream\lib\_stream_readable.js:280:11)
at FullPacketParser.Readable.push (C:\Users\Toshiba\node_modules\readable-stream\lib\_stream_readable.js:241:10)任何帮助都将是非常的感谢!
发布于 2021-01-08 15:00:12
改为:
function restartProcess() {
spawn(process.argv[1], process.argv.slice(2), {
detached: true,
stdio: ['ignore', process.stdout, process.stderr]
}).unref()https://stackoverflow.com/questions/65631307
复制相似问题