const exec = require('child_process').exec
const cmd = 'npm run start'
const cwd = 'script path'
exec(cmd, { cwd }, function (error, stdout, stderr) {
if (error) {
console.log(stderr)
return
}
console.log(`run ${cwd} successfully`)
})
node 进入指定目录并执行shell命令
最新推荐文章于 2024-01-11 03:23:50 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)