Jeb*_*b50 1 azure visual-studio-code angular
本文档的第 13 步表示“从下拉列表中选择 Debug Express 和 Angular,然后按 F5 启动调试器”。按F5得到
Error: The func task detection didn't contribute a task for the following configuration:
{
    "type": "func",
    "command": "host start",
    "problemMatcher": "$func-watch",
    "isBackground": true,
    "dependsOn": "npm build",
    "options": {
        "cwd": "${workspaceFolder}/functions"
    }
}
Run Code Online (Sandbox Code Playgroud)
相信它的意思是tasks.json,第34行。这是Angular + Node/Express的MS代码项目。导致 API 处的断点未绑定,终端显示
[HPM] Error occurred while trying to proxy request /api/vacations/ 
from localhost:4200 
to http://localhost:7070 (ECONNREFUSED) 
(https://nodejs.org/api/errors.html#errors_common_system_errors)
Run Code Online (Sandbox Code Playgroud)
如何配置task?
小智 6
错误:func 任务检测没有为以下配置提供任务:{ "type": "func", "command": "host start", "problemMatcher": "$func-watch", "isBackground": true, "dependsOn": "npm build", "options": { "cwd": "${workspaceFolder}/functions" } }
更改tasks.json 时必须重新启动VSCode。重启后一切就可以正常工作了。这里有一个类似的讨论,请参考 这里修复错误
[HPM] 尝试将请求 /api/vacations/ 从 localhost:4200 代理到 http://localhost:7070 时出错 (ECONNREFUSED) ( https://nodejs.org/api/errors.html#errors_common_system_errors )
上面的错误意味着没有任何东西在运行http://localhost:4000。您的设置似乎存在一些问题:
首先,您的developMiddleware设置指向http://localhost:4000,但您的服务器(server.js)默认运行在http://localhost:3000。也许您忘记启动服务器,或者在错误的端口启动它?
其次,如果我没看错的话,在你的代理中间件中,你正在代理到端口 4000 的每条路由?这将使盖茨比毫无用处。这是更好的代理设置的示例:
module.exports = {
    developMiddleware: app => {
        app.use(
            "/api",
            proxy({
                target: "http://localhost:4000",
            })
        )
    },
}
Run Code Online (Sandbox Code Playgroud)
这样,只有请求localhost:8000/api才会被代理到localhost:4000
参考这里
|   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           4592 次  |  
        
|   最近记录:  |