@angular/cli 改變默認啓動端口兩種方式

由於本地但願開啓兩個項目,因爲@angular/cli 生成項目默認是: 4200; 那麼確定會有端口衝突問題;node

修改端口的兩種方式:json

1 修改 schema.jsonui

node_modules\@angular-devkit\build-angular\src\dev-server\schema.json
{
  "title": "Dev Server Target",
  "description": "Dev Server target options for Build Facade.",
  "type": "object",
  "properties": {
    "browserTarget": {
      "type": "string",
      "description": "Target to serve."
    },
    "port": {
      "type": "number",
      "description": "Port to listen on.",
      "default": *4200*
    },
    "host": {
      "type": "string",
      "description": "Host to listen on.",
      "default": "localhost"
    },
    "proxyConfig": {
      "type": "string",
      "description": "Proxy configuration file."
    },
    ...
    ...
  }
}

2 第二種方式經過 --port 方式 package.json中修改code

"start": "ng serve  --port 5200",

推薦用第二種server

相關文章
相關標籤/搜索