I'm executing a code file form azure scm console with node . It give the error: "'canvasDataCli' is not recognized as an internal or external command, operable program or batch file."
I can run the canvasDataCli sync command directly from console successfully as:
canvasDataCli sync -c ./config.js
Here is the code file, test.js
var Promise = require('promise');
require('canvas-data-cli');
var s='./config.js';
var command=`canvasDataCli sync -c ${s}`;
function exec_command_promise(cmd) {
return new Promise(function (resolve, reject) {
var exec = require('child_process').exec;
var child_process = exec(cmd);
// event : stdout
child_process.stdout.on('data', data => {
console.log(data);
});
// event : stderr
child_process.stderr.on('data', data => {
console.log(data);
reject(data);
});
// event : close
child_process.on('close', data => {
console.log(data);
resolve(data);
});
});
};
I solved my problem by installing the same package at global scope i.e., canvas-data-cli at
my-site.scm.azurewebsites.net/debugConsole
npm install canvas-data-cli -g
I think the issue was that, canvasDataCli sync command create a new process, which was being run at my-site.scm.azurewebsites.net/ and I was executing it from
my-site.scm.azurewebsites.net/dev/wwwroot/