LoginSignup
2
4

More than 5 years have passed since last update.

angular-cliで開発サーバーのポート番号変更

Last updated at Posted at 2017-09-08

確認した環境

$ ng --version
@angular/cli: 1.3.0
node: 8.1.3
os: darwin x64

上記バージョンのangular-cliで作成した、angularプロジェクトが対象です。

変更する

.angular-cli.jsonのdefaults->serve->portの項目を編集します。
angular-cliで作成した直後の状態だと項目自体がないので、追加します。
下記の例では、デフォルトの4200から4201に変更しています。

変更前

.angular-cli.json
...
  "defaults": {
    "styleExt": "css",
    "component": {}
  }
}

変更後

.angular-cli.json
...

  "defaults": {
    "styleExt": "css",
    "component": {},
    "serve": {
      "port": 4201
    }
  }
}

確認

$ ng serve

次のように、変更したポート番号で開発サーバーが起動していることが確認出来ると思います。

スクリーンショット_2017-09-08_16_01_44.png

2
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
4