How to change the server port from 3000?

后端 未结 7 1475
执笔经年
执笔经年 2021-02-07 03:57

I just ended the tutorial of Angular 2 and I can\'t find a way to change the localhost port from 3000 to 8000. In my package.json file there\'s the line \"sta

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-07 04:09

    1-> Using File Default Config- Angular-cli comes from the ember-cli project. To run the application on specific port, create an .ember-cli file in the project root. Add your JSON config in there:

    { "port": 1337 }

    2->Using Command Line Tool Run this command in Angular-Cli

    ng serve --port 1234

    To change the port number permanently:

    Goto

    node_modules/angular-cli/commands/server.js

    Search for var defaultPort = process.env.PORT || 4200; (change 4200 to anything else you want).

提交回复
热议问题