如何从3000更改服务器端口?

Jp_*_*Jp_ 17 npm angular

我刚刚结束了Angular 2的教程,我找不到将localhost端口从3000更改为8000的方法.在我的package.json文件中有"start": "concurrent \"npm run tsc:w\" \"npm run lite\" "我认为相关的行,但我不确定.

Kal*_*man 19

您可以bs-config.json在文档中更改它,如文档https://github.com/johnpapa/lite-server#custom-configuration中所述

例如,

{
  "port": 8000,
  "files": ["./src/**/*.{html,htm,css,js}"],
  "server": { "baseDir": "./src" }
}
Run Code Online (Sandbox Code Playgroud)


Hod*_*lem 11

使用Angular 4和随附的cli,我能够启动服务器$npm start -- --port 8000.这工作正常:** NG Live Development Server is listening on localhost:8000, open your browser on http://localhost:8000 **

这里得到了提示

在此输入图像描述 在此输入图像描述


Aks*_*hra 7

1->使用文件默认配置 - Angular-cli来自ember-cli项目.要在特定端口上运行应用程序,请在项目根目录中创建.ember-cli文件.在那里添加您的JSON配置:

{"port":1337}

2->使用命令行工具在Angular-Cli中运行此命令

ng serve --port 1234

要永久更改端口号:

node_modules /角-CLI /命​​令/ server.js

搜索var defaultPort = process.env.PORT || 4200;(将4200更改为您想要的任何其他内容).