NodeJS无法转到该文件夹​​以执行child_process.spawn中的命令

时间:2018-12-03 08:29:14

标签: javascript node.js webpack gulp

我要使用Gulp启动WebPack(位于父文件夹中),但是一旦尝试转到路径中的父文件夹,就会出现错误。

大嘴

var spawn = require('child_process').spawn;

gulp.task('_Scada2', function (done) {
  spawn('webpack', [], { cwd: '../../Scada.Web/' })
    .on('close', done);
});

遇到错误

[14:20:47] '_Scada2' errored after 4.47 ms
[14:20:47] Error: spawn webpack ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:229:19)
    at onErrorNT (internal/child_process.js:406:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
Процесс завершен с кодом 1.

1 个答案:

答案 0 :(得分:-1)

尝试__dirname + '../../Scada.Web/'