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



我是新的VS Code,想更改用于启动我的Angular项目的任务的端口。我知道ng server --port=8080npm start -- --port=8080命令。然而,我找不到如何将端口传递到以下任务中。json.

  1. 我尝试将参数附加到脚本值
  2. 我尝试在选项中添加端口键值->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
},
}

最新更新