NodeJs child_process working directory

前端 未结 1 1399
日久生厌
日久生厌 2020-12-14 00:10

I am trying to execute a child process in a different directory then the one of its parent.

var exec = require(\'child_process\').exec;

exec(
    \'pwd\',
         


        
相关标签:
1条回答
  • 2020-12-14 00:39

    The option is short for current working directory, and is spelled cwd, not cdw.

    var exec = require('child_process').exec;
    exec('pwd', {
      cwd: '/home/user/directory'
    }, function(error, stdout, stderr) {
      // work with result
    });
    
    0 讨论(0)
提交回复
热议问题