Using spawn function with NODE_ENV=production

前端 未结 4 665
天命终不由人
天命终不由人 2021-02-02 07:42

I\'m currently trying to run process using spawn. What I am trying to run from shell is the following;

NODE_ENV=production node app/app.js

4条回答
  •  星月不相逢
    2021-02-02 08:10

    add shell option worked for me

    gulp.task('xxx', function (callback) {
        process.chdir('xxx/');
        var spawn = require('child_process').spawn;
        var productionEnv = Object.create(process.env);
        // var jekyll = spawn('gulp', ['stylecheck'], {stdio: 'inherit', env: productionEnv});
        var jekyll = spawn('gulp', ['stylecheck'], {stdio: 'inherit', env: productionEnv, shell: true});
    
        jekyll.on('exit', function (code) {
            console.log(arguments);
        });
    });
    

提交回复
热议问题