如何更改Angular快速入门中的默认lite-server端口?

时间:2017-04-21 10:23:50

标签: node.js angular lite-server

我刚刚下载了Angular 4快速入门应用,并尝试通过将"port": 8000添加到bs-config.json来更改默认的lite-server端口,如下所示:

{
  "server": {
    "port": 8000,
    "baseDir": "src",
    "routes": {
      "/node_modules": "node_modules"
    }
  }
}

当我npm start该应用时,我看到bs-config.json已正常阅读,但lite-server仍然继续使用默认端口3000

 >angular-quickstart@1.0.0 serve /Users/me/code/quickstart
[1] > lite-server -c=bs-config.json
[1] 
[1] ** browser-sync config **
[1] { injectChanges: false,
[1]   files: [ './**/*.{html,htm,css,js}' ],
[1]   watchOptions: { ignored: 'node_modules' },
[1]   server: 
[1]    { baseDir: 'src',
[1]      middleware: [ [Function], [Function] ],
[1]      port: 8000,
[1]      routes: { '/node_modules': 'node_modules' } } }
[1] [BS] Access URLs:
[1]  -------------------------------------
[1]        Local: http://localhost:3000
[1]     External: http://192.168.1.12:3000
[1]  -------------------------------------
[1]           UI: http://localhost:3001
[1]  UI External: http://192.168.1.12:3001
[1]  -------------------------------------
[1] [BS] Serving files from: src
[1] [BS] Watching files...

我错过了什么?

1 个答案:

答案 0 :(得分:3)

基于the documentation,您应该将端口声明为顶级:

{
  "port": 8000,
  "server": {
    "baseDir": "src",
    "routes": {
      "/node_modules": "node_modules"
    }
  }
}