Search code examples
azure-web-app-servicebotframework

azure app service ('bf' is not recognized as an internal or external command)


I have an issue with using ["@microsoft/botframework-cli": "^4.14.1"] library in my nodejs project. Below is my sample snippet of my project. I'm just executing few bf commands with help from node-cmd library.

const http = require('http');
const shell = require('node-cmd');
const server = http.createServer(async (req, res) => {
  cmd = `bf orchestrator:basemodel:get --out ./model`
  await shell.runSync(cmd);
  res.writeHead(200, {"Content-Type": "text/plain"});
  res.end("Process completed");
});
const port = process.env.PORT || 1337;
server.listen(port);
console.log('SERVER RUNNING AT',port);

The above code works fine in my local. But when i deploy the same code to azure web app, i'm getting

'bf' is not recognized as an internal or external command

I navigated to the KUDU editor and checked if botframework node_modules are installed properly. Library was installed correctly though. I Even tried with Azure functions. But its still the same. Please help me to resolve this.


Solution

  • In npm install reads package.json to create a list of dependencies and uses package-lock.json to inform which versions of these dependencies to install. If a dependency is not in package-lock.json it will be added by npm install.

    npm ci (named after Continuous Integration) installs dependencies directly from package-lock.json and uses package.json only to validate that there are no mismatched versions. If any dependencies are missing or have incompatible versions, it will throw an error. Check here

    Instead of using npm install You can use the npm ci

    "scripts": {
        "install": "npm ci",
    }
    

    or

    "scripts": {
        "install": "npm ci @microsoft/botframework-cli",
    }
    

    Refer here