方法一:修改配置文件node_modules/angular-cli/commands/server.js
default值就是默认的端口:4200
"use strict"; var assign = require('lodash/assign'); var denodeify = require('denodeify'); var Command = require('../ember-cli/lib/models/command'); var SilentError = require('silent-error'); var PortFinder = require('portfinder'); var serve_webpack_1 = require('../tasks/serve-webpack'); PortFinder.basePort = 49152; var getPort = denodeify(PortFinder.getPort); var defaultPort = process.env.PORT || 4200;
在package.json 里:
{ "name": "Console","version": "3.1.0","description": "Console","main": "electron.main.ts","angular-cli": {},"scripts": { "ngstart": "ng serve","lint": "tslint \"src/**/*.ts\"","test": "ng test","pree2e": "webdriver-manager update","e2e": "protractor","startauth": "node nodejs-jwt-authentication-sample/server.js","start": "concurrently -k --no-color --raw \"npm run startauth\" \"ng serve --port 4100 --proxy-config proxy.conf.json\" ","start:electron": "electron .","build": "ng build","server": "http-server ./dist --cors" } }
ng server --port 4100
选择直接在package.json 里修改是比较方便的
原文链接:https://www.f2er.com/angularjs/145636.html