【发布时间】:2020-02-14 20:52:24
【问题描述】:
当我的 windows 服务器收到一个 post 请求时,我需要它来执行一个命令:
cd D:\project
git pull
mvn clean compile
cd target
java -jar app.jar -argument
我写了代码,但它不起作用:
const nodeCmd = require('node-cmd')
app.post((req, res) => {
let command = `cd D:\project\my_project
git pull
mvn clean compile
cd target
java -jar app.jar ${req.body.arg}`;
nodeCmd.get(command, (err, data, stderr) => {
if(data) {
return res.json(data);
}
return err;
});
})
这里是错误信息:
{ Error: Command failed: cd D:projectmy_project && dir
The system cannot find the path specified.
at ChildProcess.exithandler (child_process.js:294:12)
at ChildProcess.emit (events.js:198:13)
at maybeClose (internal/child_process.js:982:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
killed: false,
code: 1,
signal: null,
cmd: 'cd D:Tempautobooker && dir' }
【问题讨论】:
-
你能告诉我们错误信息吗?
-
我用错误堆栈跟踪更新了我的问题
标签: node.js windows command-line automation