简体   繁体   English

Node.js child_process 中的错误代码 255 是什么意思

[英]What does error code 255 mean in Node.js child_process

I am running php command from Node.js child_process.我正在从 Node.js child_process 运行 php 命令。 In response it is showing error and throwing error with error code 255 because of which my script is breaking.作为响应,它显示错误并抛出错误代码为 255 的错误,因此我的脚本正在中断。

When i execute the command from terminal it works fine but in child_process it gives error.当我从终端执行命令时,它工作正常,但在 child_process 中它会出错。

async function decrypt(cipher){

    try {
        var terminal = require('child_process');
    var util     = require('util');
    var exec     = util.promisify(terminal.exec);
    var command  = "usr/bin/php " + basePath + "/decrypt.php '" + cipher +"'";

    return await exec(command);
    }catch(err){
        console.log(err);
        console.error(err.code +' | '+ err.message);
    }
}

module.exports = {
decrypt : decrypt
}




 { Error: Command failed: /usr/bin/php /var/www/html/nodejs/decrypt.php 'w5oFS8U4NGrleFHtptkmO+luDMw0z+fYrJ/onlj6fndIS/0QrWzOAsTN450VLZwR+GmDkyylybGJXUnx2VdeJQ=='



    at ChildProcess.exithandler (child_process.js:281:12)

    at emitTwo (events.js:126:13)

    at ChildProcess.emit (events.js:214:7)

    at maybeClose (internal/child_process.js:915:16)

    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

    killed: false,

    code: 255,

    signal: null,

    cmd: '/usr/bin/php /var/www/html/nodejs/decrypt.php \'w5oFS8U4NGrleFHtptkmO+luDMw0z+fYrJ/onlj6fndIS/0QrWzOAsTN450VLZwR+GmDkyylybGJXUnx2VdeJQ==\'',

    stdout: '\t\n\n{"error":false,"decryptedText":"0324"}',

    stderr: '' }

Desired Output is : '{"error":false,"decryptedText":"0324"}'所需的输出是:'{"error":false,"decryptedText":"0324"}'

The error trace stack is more important than the error code.错误跟踪堆栈比错误代码更重要。 process exit code 进程退出代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM