I am using cmd to execute my chef commands, How do i run them using node.js?
PS C:\Users\xyz\chef-repo> chef-apply script.rb
I want to run this command using node.js
exports.testscript=function(req,res){
var exec = require('child_process').exec;
console.log("inside function");
var child = exec('chef-apply azurepro.rb' ,{cwd: 'C:\Users\anurag.s\chef-repo'},
function(error, stdout, stderr){
console.log(stdout);
console.log(stderr);
if (error !== null) {
console.log(error);
}
});
//child.stdin.end();
};
this is my code. I am getting this error and my command is .bat file.
{ [Error: spawn cmd.exe ENOENT]
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn cmd.exe',
path: 'cmd.exe',
cmd: 'cmd.exe /s /c "chef-apply azurepro.rb"' }