【发布时间】:2021-05-31 06:09:23
【问题描述】:
我有一个简单的 Angular 应用程序,并在 angular.json 中使用我的端口更新了端口,
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "ceams-ui:build",
"port": 4444
},
$ ng --version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ Γû│ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 10.2.0
Node: 12.19.0
OS: win32 x64
Angular: 10.1.6
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1002.0
@angular-devkit/build-angular 0.1002.0
@angular-devkit/core 10.2.0
@angular-devkit/schematics 10.2.0
@angular/cdk 10.2.7
@angular/cli 10.2.0
@angular/flex-layout 10.0.0-beta.32
@angular/material 10.2.7
@schematics/angular 10.2.0
@schematics/update 0.1002.0
rxjs 6.6.3
typescript 4.0.5
$ ng serve 成功为 日期:2021-03-01T17:18:10.880Z - 哈希:8144cdb2f65873b9a965 - 时间:31537ms ** Angular Live Development Server 正在监听 localhost:4444,在 http://localhost:4444/ 上打开浏览器 ** : 编译成功。
在本地浏览器上,它总是错误输出为, 无法访问此网站。
而我的“curl http://localhost:4444/”成功了。 它与默认端口 4200 完美配合。不知道发生了什么 观察:netstat -tln 输出, 试过但没有运气。一项观察“netstat -tln”将本地 IP 设为“127.0.0.1”,但对于 4200 则不同,
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:4200 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:4444 0.0.0.0:* LISTEN
【问题讨论】:
-
ng 服务...成功..?但是如果你在浏览器中访问 localhost:4444 会失败..?
-
@MikeOne 是的,ng serve 成功了,即使使用 'ng serve --port 4444' 也成功了。但是在我的本地浏览器上它失败了。
标签: node.js angular nginx port