Azure functions 由于VSCode上存在未处理的错误,func命令失败

Azure functions 由于VSCode上存在未处理的错误,func命令失败,azure-functions,func,azure-cli,azure-functions-core-tools,Azure Functions,Func,Azure Cli,Azure Functions Core Tools,我想在VSCode上运行func命令,但错误如下 <UserName>@W10-1911039 MINGW64 ~ $ func events.js:200 throw er; // Unhandled 'error' event ^ Error: spawn C:\Users\<UserName>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin/func ENOEN

我想在VSCode上运行
func
命令,但错误如下

<UserName>@W10-1911039 MINGW64 ~
$ func
events.js:200
      throw er; // Unhandled 'error' event
      ^

Error: spawn C:\Users\<UserName>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin/func ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:81:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn C:\\Users\\<UserName>\\AppData\\Roaming\\npm\\node_modules\\azure-functions-core-tools\\bin/func',
  path: 'C:\\Users\\<UserName>\\AppData\\Roaming\\npm\\node_modules\\azure-functions-core-tools\\bin/func',
  spawnargs: []
}
<UserName>@W10-1911039 MINGW64 ~
$ npm list -g | grep azure

<UserName>@W10-1911039 MINGW64 ~
$ npm install -g azure-functions-core-tools
C:\Users\<UserName>\AppData\Roaming\npm\azurefunctions -> C:\Users\<UserName>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\lib\main.js
C:\Users\<UserName>\AppData\Roaming\npm\func -> C:\Users\<UserName>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\lib\main.js
C:\Users\<UserName>\AppData\Roaming\npm\azfun -> C:\Users\<UserName>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\lib\main.js

> azure-functions-core-tools@2.7.2184 postinstall C:\Users\<UserName>\AppData\Roaming\npm\node_modules\azure-functions-core-tools
> node lib/install.js

attempting to GET "https://functionscdn.azureedge.net/public/2.7.2184/Azure.Functions.Cli.win-x64.2.7.2184.zip"
using proxy server "http://<CompanyProxyHost>:<PortNumber>"
Error: self signed certificate in certificate chain
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! azure-functions-core-tools@2.7.2184 postinstall: `node lib/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the azure-functions-core-tools@2.7.2184 postinstall 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\<UserName>\AppData\Roaming\npm-cache\_logs\2020-02-13T04_55_46_986Z-debug.log
<UserName>@W10-1911039 MINGW64 ~
$ npm install -g azure-functions-core-tools
C:\Users\<UserName>\AppData\Roaming\npm\azfun -> C:\Users\<UserName>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\lib\main.js
C:\Users\<UserName>\AppData\Roaming\npm\azurefunctions -> C:\Users\<UserName>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\lib\main.js
C:\Users\<UserName>\AppData\Roaming\npm\func -> C:\Users\<UserName>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\lib\main.js

> azure-functions-core-tools@2.7.2184 postinstall C:\Users\<UserName>\AppData\Roaming\npm\node_modules\azure-functions-core-tools
> node lib/install.js

attempting to GET "https://functionscdn.azureedge.net/public/2.7.2184/Azure.Functions.Cli.win-x64.2.7.2184.zip"
using proxy server "http://<CompanyProxyHost>:<PortNumber>/"
Error: self signed certificate in certificate chain
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! azure-functions-core-tools@2.7.2184 postinstall: `node lib/install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the azure-functions-core-tools@2.7.2184 postinstall 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\<UserName>\AppData\Roaming\npm-cache\_logs\2020-02-13T09_54_42_193Z-debug.log

附加步骤2 我在VSCode上的
settings.json
中设置了以下内容

{
    "http.proxy": "http://<CompanyProxyHost>:<PortNumber>",
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    "http.proxyStrictSSL": false
}

附加步骤3 我在
~/.npmrc
中运行
npm-config-set-proxy http://://://
npm-config-set-strict-ssl-false
,并尝试重新安装
azure函数核心工具
,但错误如下

<UserName>@W10-1911039 MINGW64 ~
$ npm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.13.4 node/v12.14.1 win32 x64"

; userconfig C:\Users\<UserName>\.npmrc
proxy = "http://<CompanyProxyHost>:<PortNumber>/"
strict-ssl = false

; builtin config undefined
prefix = "C:\\Users\\<UserName>\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\Users\<UserName>
; HOME = C:\Users\<UserName>
; "npm config ls -l" to show all defaults.


<UserName>@W10-1911039 MINGW64 ~
$ npm install -g azure-functions-core-tools
npm ERR! code EEXIST
npm ERR! path C:\Users\<UserName>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\lib\main.js
npm ERR! dest C:\Users\<UserName>\AppData\Roaming\npm\azfun
npm ERR! EEXIST: file already exists, cmd shim 'C:\Users\<UserName>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\lib\main.js' -> 'C:\Users\<UserName>\AppData\Roaming\npm\azfun'
npm ERR! File exists: C:\Users\<UserName>\AppData\Roaming\npm\azfun
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\<UserName>\AppData\Roaming\npm-cache\_logs\2020-02-14T02_00_32_376Z-debug.log
@W10-1911039明w64~
$npm配置列表
; cli配置
度量注册表=”https://registry.npmjs.org/"
scope=“”
用户代理=“npm/6.13.4节点/v12.14.1 win32 x64”
; 用户配置C:\Users\\.npmrc
proxy=“http://:/”
严格ssl=false
; 内置配置未定义
prefix=“C:\\Users\\\\AppData\\Roaming\\npm”
; node bin location=C:\Program Files\nodejs\node.exe
; cwd=C:\用户\
; HOME=C:\用户\
; “npm config ls-l”以显示所有默认值。
@W10-1911039明W64~
$npm安装-g azure功能核心工具
npm错误!代码EEXIST
npm错误!路径C:\Users\\AppData\Roaming\npm\node\u modules\azure函数核心工具\lib\main.js
npm错误!目标C:\Users\\AppData\Roaming\npm\azfun
npm错误!EEXIST:文件已存在,cmd shim'C:\Users\\AppData\Roaming\npm\node\u modules\azure functions核心工具\lib\main.js'->'C:\Users\\AppData\Roaming\npm\azfun'
npm错误!文件存在:C:\Users\\AppData\Roaming\npm\azfun
npm错误!请删除现有文件并重试,或运行npm
npm错误!使用--force轻率地覆盖文件。
npm错误!此运行的完整日志可在以下位置找到:
npm错误!C:\Users\\AppData\Roaming\npm cache\\ u logs\2020-02-14T02\u 00\u 32\u 376Z-debug.log

因此,我尝试使用
--force
选项重新安装
azure functions core tools
,但错误返回到“附加步骤1”

您的第一次安装似乎失败了,尝试删除C:\Users\\AppData\Roaming\npm\node\u modules\azure功能核心工具并重新安装。感谢您的评论。我试着按照你教的步骤做,但错误在上面。你现在遇到的问题应该是,它与你公司的网络代理有关。链接中给出了解决方案。在settings.json文件中使用
“http.proxyStrictSSL”:false
。感谢您的评论。我试着做你教的步骤,但错误在上面。嗨,看看这个: