gpt4 book ai didi

node.js - Node 失败退出代码 1

转载 作者:行者123 更新时间:2023-12-05 07:28:00 25 4
gpt4 key购买 nike

我正在尝试使用以下代码通过 childprocess execsync 运行 photoshop 脚本,但出现错误

try {
const child_process = require("child_process")
child_process.execSync('"C:/Program Files/Adobe/Adobe Photoshop CC 2019/Photoshop.exe" Z:/myfile.jsx', (err, stdout, stderr) => {
if (err) {
console.log("error here");
}
})
.on('close', function (code, signal) {console.log('go to next step')})
} catch (err) {
err.stdout;
err.stderr;
err.pid;
err.signal;
err.status;
}

但是我得到一个错误

{ Error: Command failed: "C:/Program Files/Adobe/Adobe Photoshop CC 2019/Photoshop.exe" Z:/Render2.0/psTextConvertor.jsx
at checkExecSyncError (child_process.js:611:11)
at Object.execSync (child_process.js:648:13)
at startPhotoshop (Z:\Render2.0\tempsqs.js:422:23)
at mergeFontData (Z:\Render2.0\tempsqs.js:410:9)
at ChildProcess.<anonymous> (Z:\Render2.0\tempsqs.js:282:21)
at ChildProcess.emit (events.js:187:15)
at ChildProcess.EventEmitter.emit (domain.js:442:20)
at maybeClose (internal/child_process.js:962:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
status: 1,
signal: null,
output: [ null, <Buffer >, <Buffer > ],
pid: 5492,
stdout: <Buffer >,
stderr: <Buffer > }

但脚本运行完美,但我没有得到退出代码,请帮忙

最佳答案

我在让 Photoshop 从 Node 启动和运行脚本作为子进程时遇到了类似的问题。当时我在使用 Adob​​e CS6 的 Windows 系统上工作,并且能够通过编写一个 powershell 脚本来启动带有 args 的 photoshop 来执行 ExtendScript 文件来实现这一点,然后使用 child -process.exec 从 Node 运行该 powershell 脚本。

电源外壳:

Start-Process -FilePath  "C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\Photoshop.exe" -ArgumentList "C:\Scripts\MyScript.jsx" -Wait

Node :

function runPowershell(path) {

var spawn = require("child_process").exec, child;

child = spawn(`powershell -ExecutionPolicy Bypass -File ${path} -NoExit`);
child.stdout.on("data", function (data) {
console.log("Powershell Data: " + data);
});
child.stderr.on("data", function (data) {
console.log("Powershell Errors: " + data);
});
child.on("exit", function () {
console.log("Powershell Script finished");
});
child.stdin.end(); //end input
}

runPowershell("path/to/powershellScript.ps1");

关于node.js - Node 失败退出代码 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53632588/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com