angular cli 修改启动端口

前端之家收集整理的这篇文章主要介绍了angular cli 修改启动端口前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

方法一:修改配置文件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

猜你在找的Angularjs相关文章