ng config projects.my-test-project.targets.serve.options.port 4201
其中 my-test-project部分是您使用 ng new命令设置的项目名,如下所示:
$ ng new my-test-project
$ cd my-test-project
$ ng config projects.my-test-project.targets.serve.options.port 4201
$ ng serve
** Angular Live Development Server is listening on localhost:4201, open your browser on http://localhost:4201/ **