在同时运行两个ng项目的时候,会提示端口冲突,因为它们的端口号都默认的是4200,这时候,就需要修改其中一个项目的端口号了。有两种修改途径,如下。
(1)去对应的文件里面修改代码,angular的版本不同,可能目录也不同。如下图:
angular5中,/nodemodules/@angular/cli/lib/config/schema.json
"serve": { "description": "Properties to be passed to the serve command.", "type": "object", "properties": { "port": { "description": "The port the application will be served on.", "type": "number", "default": 4200 //修改之 }
}
}
(2)直接命令行修改
ng server --port 4201