node.jsazureazure-functions-core-tools

azure-functions-core-tools : while running "func init" command fails


On executing 'func init' command from an empty directory to create a azure function fails with following error:

events.js:298
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\Users\<XYZ>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin/func ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn C:\\Users\\<XYZ>\\AppData\\Roaming\\npm\\node_modules\\azure-functions-core-tools\\bin/func',
  path: 'C:\\Users\\<XYZ>\\AppData\\Roaming\\npm\\node_modules\\azure-functions-core-tools\\bin/func',
  spawnargs: [ 'init' ]
}

Anyone any suggestions on the same?


Solution

  • Thanks for the update @silent . Googling the same, I also did land into the same link.

    To followup on the suggestions at the Github, I had to perform following steps:

    1. Go to the folder:
    C:\Users\< XYZ >\AppData\Roaming\npm\node_modules\azure-functions-core-tools
    
    1. Open the package.json file in an editor
    2. Modify the version for "unzipper" module under dependencies from '0.10.5' to '0.10.8'.
     "dependencies": {
        "chalk": "3.0.0",
        "command-exists": "1.2.8",
        "glob": "7.1.6",
        "https-proxy-agent": "3.0.1",
        "progress": "2.0.3",
        "rimraf": "3.0.0",
        "tmp": "0.1.0",
        "unzipper": "0.10.8"
      },
    
    1. Delete "node_modules" folder under this directory.
    2. Run "npm install" command from this directory on command-prompt.

    Remember to replace "< XYZ >" with your own Username on the machine.