Azure-functions-core-tools: Any `func` command does not work

Created on 5 Feb 2020  ยท  12Comments  ยท  Source: Azure/azure-functions-core-tools

I installed the package globally, created a new project through VSCode extension and tried to run the sample without any changes. The error I get is:

> func start

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

Error: spawn C:\Users\apricot\AppData\Roaming\nvm\v13.7.0\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\\apricot\\AppData\\Roaming\\nvm\\v13.7.0\\node_modules\\azure-functions-core-tools\\bin/func',
  path: 'C:\\Users\\apricot\\AppData\\Roaming\\nvm\\v13.7.0\\node_modules\\azure-functions-core-tools\\bin/func',
  spawnargs: [ 'start' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `func start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.        

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\apricot\AppData\Roaming\npm-cache\_logs\2020-02-05T09_13_13_764Z-debug.log

So, how about func itself?

C:\Users\apricot\src\user\directory\hogehoge>func init fugafuga
events.js:298
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\Users\apricot\AppData\Roaming\nvm\v13.7.0\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\\apricot\\AppData\\Roaming\\nvm\\v13.7.0\\node_modules\\azure-functions-core-tools\\bin/func',
  path: 'C:\\Users\\apricot\\AppData\\Roaming\\nvm\\v13.7.0\\node_modules\\azure-functions-core-tools\\bin/func',
  spawnargs: [ 'init', 'fugafuga' ]
}

What happens in line 298...?
I installed both 2.7.2100 and 3.0.2106 but neither has worked.

investigate

All 12 comments

Getting same issue. It appears that the func.exe application is not getting installed via NPM. I worked around this by downloading the zip from https://functionscdn.azureedge.net/public/3.0.2106/Azure.Functions.Cli.win-x64.3.0.2106.zip and extracting it into the bin folder manually.

It appears to be an issue with the install.js script. I got the following error when installing via NPM

npm install -i g azure-functions-core-tools@3 --unsafe-perm true 

> [email protected] postinstall C:\node_modules\azure-functions-core-tools
> node lib/install.js

attempting to GET "https://functionscdn.azureedge.net/public/3.0.2106/Azure.Functions.Cli.win-x64.3.0.2106.zip"
[------------------] Downloading Azure Functions Core Toolsnpm WARN saveError ENOENT: no such file or directory, open 'C:\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'C:\package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN !invalid#1 No license field.

+ [email protected]
+ [email protected]
added 54 packages from 34 contributors and audited 112 packages in 1.591s

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities

@joshuapetryk, your error is because you have g instead of -g in the install command. It needs to be npm install -g azure-functions-core-tools@3 --unsafe-perm true

@seed-of-apricot, are other npm packages working ok for you, if you have them? What happens when you do C:\Users\apricot\AppData\Roaming\nvm\v13.7.0\node_modules\azure-functions-core-tools\bin\func --version

Can you check the contents of C:\Users\apricot\AppData\Roaming\nvm\v13.7.0\node_modules\azure-functions-core-tools\bin ?

And if nothing works, I would suggest removing C:\Users\apricot\AppData\Roaming\nvm\v13.7.0\node_modules\azure-functions-core-tools and installing core-tools again. I can't repro this and I think it's likely that your first install somehow didn't complete properly.

I'm having the same problem. After installing with the npm install -g azure-functions-core-tools@3 --unsafe-perm true command, func calls don't work. There is no bin folder added to azure-functions-core-tools in node_modules.

This install process looks like this:

โฏ npm install -g azure-functions-core-tools@3 --unsafe-perm true
C:\Users\Michael.Currie\AppData\Roaming\npm\func -> C:\Users\Michael.Currie\AppData\Roaming\npm\node_modules\azure-functions-core-tools\lib\main.js
C:\Users\Michael.Currie\AppData\Roaming\npm\azurefunctions -> C:\Users\Michael.Currie\AppData\Roaming\npm\node_modules\azure-functions-core-tools\lib\main.js
C:\Users\Michael.Currie\AppData\Roaming\npm\azfun -> C:\Users\Michael.Currie\AppData\Roaming\npm\node_modules\azure-functions-core-tools\lib\main.js

> [email protected] postinstall C:\Users\Michael.Currie\AppData\Roaming\npm\node_modules\azure-functions-core-tools
> node lib/install.js

attempting to GET "https://functionscdn.azureedge.net/public/3.0.2106/Azure.Functions.Cli.win-x64.3.0.2106.zip"
[------------------] Downloading Azure Functions Core Tools+ [email protected]
added 53 packages from 33 contributors in 1.278s

It never downloads a 219 MB zip and finishes in a few seconds.

The issue persists through uninstalls/reinstalls.

Thanks - Missed the -g switch. I am still getting the same issue though - the zip file doesn't actually download.

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

I'm getting the same error.

I've used 'npm i -g azure-functions-core-tools@3 --unsafe-perm true' to install the tools from an elevated command prompt (Windows Terminal) it installs fine, but any func command results in the mentioned error.

uninstalling then reinstalling does not solve the issue.

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

Same issue with me. Looking at the error message:

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

Error: spawn C:\Users\sgcol\AppData\Roaming\nvm\v13.8.0\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\\sgcol\\AppData\\Roaming\\nvm\\v13.8.0\\node_modules\\azure-functions-core-tools\\bin/func',  
  path: 'C:\\Users\\sgcol\\AppData\\Roaming\\nvm\\v13.8.0\\node_modules\\azure-functions-core-tools\\bin/func',
  spawnargs: [ 'host', 'start' ]
}
The terminal process terminated with exit code: 1

I think the key problem may be the path: C:\Users\sgcol\AppData\Roaming\nvm\v13.8.0\node_modules\azure-functions-core-tools\bin/func. The final path delimiter is a forward slash on my Windows machine. I'm guessing that's why it can't find the file.

If someone can point me in the right direction of where this path is put together, I'd be happy to bring in a PR for it.

@nibblesnbits looks like that is here: https://github.com/Azure/azure-functions-core-tools/blob/dev/src/Azure.Functions.Cli/npm/lib/main.js#L12

This probably should use path.join, maybe a recent change in Node caused this to no longer work.

// @ankitkumarr

Thank you all for your patience. Thanks @mhoeger for finding the root cause (below) offline!

The issue was during the unzip step where unzipper (we use to unzip) would, intermittently, exit abruptly when using Node 13. Marie was able to repro, and found that this issue was likely the cause - https://github.com/ZJONSSON/node-unzipper/issues/168

Once we updated the unzipper package in the repro, the issue seemed to have resolved. We need to update our package.json and npm-shrinkwrap.json. @nibblesnbits, if you would like to make a PR to update https://github.com/Azure/azure-functions-core-tools/blob/dev/src/Azure.Functions.Cli/npm/package.json and https://github.com/Azure/azure-functions-core-tools/blob/dev/src/Azure.Functions.Cli/npm/npm-shrinkwrap.json with a newer version of unzipper, you are more than welcome to do so. :)

For now, if this happens you can follow these steps to mitigate yourselves --

  1. Go to the installed location.C:\Users\sgcol\AppData\Roaming\nvm\v13.8.0\node_modules\azure-functions-core-tools\ in the example above.
  2. Run npm install [email protected]
  3. Run npm .\lib\install.js node .\lib\install.js from that directory

These steps should download and extract the core-tools to the bin location and have it setup for executions.
Please let us know if you continue to see issues.

@ankitkumarr Sorry for not responding to your mention for a while.

I have tried the steps you described in the latest comment and made it work, thank you!
(You though misattributed npm .\lib\install.js with node .\lib\install.js)

@seed-of-apricot, thanks for the update. I will update my comment. With the interest of time in mind, we updated the packages and this should be fixed in the next release.

Was this page helpful?
0 / 5 - 0 ratings