Angular 在VS代码中更改角度任务的任务端口

Angular 在VS代码中更改角度任务的任务端口,angular,visual-studio-code,Angular,Visual Studio Code,我是新的VS代码,希望更改用于启动角度项目的任务的端口。我知道ng server--port=8080和npm start--port=8080命令。但是,我无法找到如何将端口传递到下面的tasks.json中 我尝试将参数附加到脚本值 我尝试在options->env中添加端口键值 我很抱歉问这个琐碎的问题,但我不能相信npm任务类型不允许更改端口值 { "version": "2.0.0", "tasks": [

我是新的VS代码,希望更改用于启动角度项目的任务的端口。我知道
ng server--port=8080
npm start--port=8080
命令。但是,我无法找到如何将端口传递到下面的tasks.json中

  • 我尝试将参数附加到脚本值
  • 我尝试在options->env中添加端口键值
  • 我很抱歉问这个琐碎的问题,但我不能相信npm任务类型不允许更改端口值

    {
        "version": "2.0.0",
        "tasks": [
          {
            "type": "npm",
            "script": "start",
            "isBackground": true,
            "presentation": {
              "focus": true,
              "panel": "dedicated"
            },
            "group": {
              "kind": "build",
              "isDefault": true
            },
            "problemMatcher": {
              "owner": "typescript",
              "source": "ts",
              "applyTo": "closedDocuments",
              "fileLocation": [
                "relative",
                "${cwd}"
              ],
              "pattern": "$tsc",
              "background": {
                "activeOnStart": true,
                "beginsPattern": {
                  "regexp": "(.*?)"
                },
                "endsPattern": {
                  "regexp": "Compiled |Failed to compile."
                }
              }
            }
          },
        ]
      }
    

    您必须编辑angular.json并在服侍之后添加以下内容

    "serve" :{
        // add below
           "options": {
            
            "port": 8080
          },
        }
    

    谢谢,但我想实现的是在tasks.json文件中设置此端口配置,这样我就可以使用不同的端口配置多个不同的配置,然后在VSCode中“Run And Debug”字段旁边的下拉列表中选择这些端口