angular-cli 在 angular-cli.json 中将端口更改为 3000 [英] angular-cli change port to 3000 in angular-cli.json

查看:27
本文介绍了angular-cli 在 angular-cli.json 中将端口更改为 3000的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Daniel Zen 的材料 todo 应用程序,并想更改为 angular-cli.json 中的端口.https://github.com/danielzen/material-todo

i use the material todo app from Daniel Zen and want to change to port in the angular-cli.json. https://github.com/danielzen/material-todo

但这行不通.我试过这个:

But this doesn't work. I tried this:

{
  "port" : 3000,

但是什么也没发生.有人有想法吗?

But nothing happens. Anyone an idea?

推荐答案

使用 Angular-CLI 1.0.0 编辑

您现在可以通过定义如下属性直接在 .angular-cli.json 文件中定义使用的端口:

You can now directly define the used port in the .angular-cli.json file by defining the property like this:

{
    "defaults": {
        "serve": {
            "port": 2500
        }
    }
}

这里是配置所有可用选项的直接链接:Angular-CLI选项配置

Here is a direct link to all available options for the configuration: Angular-CLI options configuration

旧答案

您可以直接在您的 packages.json 中配置它,通过以下方式更改您的 start 脚本:

You can configure it directly in your packages.json, change your start scripts by:

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

然后用 npm start

这篇关于angular-cli 在 angular-cli.json 中将端口更改为 3000的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆