每当我尝试通过 yarn audit
运行 child_process.execSync
命令时,它总是抛出状态为 4 的错误,并且不知道为什么会发生这种情况,也不知道状态 4
是什么意思。无法从 child_process.execSync
的 Node js 文档中获得此状态的任何错误描述。任何有关此错误含义以及需要如何修复的帮助都会非常有帮助。
虽然我在 stdout
对象中收到了所需的输出,但我想修复这个错误。
try {
const result = execSync('yarn audit', {encoding: 'UTF-8'});
} catch (err) {
console.log(`err.stdout = ${err.stdout}`);
console.log(`err.stderr = ${err.stderr}`);
console.log(`err.pid= ${err.pid}`);
console.log(`err.signal = ${err.signal}`);
console.log(`err.status = ${err.status}`);
}
以上输出为:
err.stdout = yarn audit v1.22.10
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ moderate │ Regular Expression Denial of Service │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ xxxxx │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=4.16.5 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ xxxx │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ xxx > isyyt >xyz > │
│ │ > xxx │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://www.npmjs.com/advisories/xyz │
└───────────────┴──────────────────────────────────────────────────────────────┘
1 vulnerabilities found - Packages audited: 556
Severity: 1 Moderate
Done in 0.91s.
err.stderr =
err.pid= 13089
err.signal = null
err.status = 4