How to change angular port from 4200 to any other

后端 未结 29 1783
心在旅途
心在旅途 2020-12-04 05:59

I want to use 5000 instead of 4200.

I have tried to create a file on root name ember-cli and put JSON according to the code below:

{
   &q         


        
29条回答
  •  遥遥无期
    2020-12-04 06:20

    The location for port settings has changed a couple of times.

    If using Angular CLI 1

    Change angular-cli.json

    {
      "defaults": {
        "serve": {
          "host": "0.0.0.0",
          "port": 5000 
        }
      }
    }
    

    If using the latest Angular CLI

    Change angular.json

    "projects": {
        "project-name": {
            ...
            "architect": {
                "serve": {
                    "options": {
                      "host": "0.0.0.0",
                      "port": 5000
                    }
                }
            }
            ...
        }
    }
    

    Without changing any file

    Run the command

    ng serve --host 0.0.0.0 --port 5000
    

提交回复
热议问题