Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【Angular】如何换个端口启动项目? #153

Open
deepthan opened this issue Sep 17, 2021 · 0 comments
Open

【Angular】如何换个端口启动项目? #153

deepthan opened this issue Sep 17, 2021 · 0 comments

Comments

@deepthan
Copy link
Owner

如歌换个端口启动项目?

我想在 6666 端口启动项目

  • 方法一:在启动的时候添加参数
ng server --port 6666  
  • 方法二:修改配置文件,然后直接 ng server

在依赖包中找到@angular/cli/lib/config/schema.json,在523行或者直接搜索'port'在它键为default的地方填入 6666

 "serve": {
        ...
        "port": {
          "description": "The port the application will be served on.",
          "type": "number",
          "default": 6666
        }
}

如果你是用脚手架自动生成的项目,并且要用jasmine做单元测试的话,还需要做一步:找到protractor.conf.js文件把‘baseUrl’也改成新端口,让测试代码在改过的端口运行。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant