【问题标题】:Unable to launch project in chrome which is created using angular-cli无法在使用 angular-cli 创建的 chrome 中启动项目
【发布时间】:2017-10-25 19:06:06
【问题描述】:

使用 https://angular.io/guide/quickstart 中提到的 angular-CLI 创建一个 Angular 项目

运行ng serve

使用http://localhost:4200/访问应用程序

我可以在 Firefox 中毫无问题地访问我的 Angular 应用程序 而在 chrome 中我得到了

“拒绝连接”错误。 无法访问此站点 localhost 拒绝连接。

我尝试更改不同的端口,但没有一个对我有用。

取消注释后在 IE 中,polyfills 中的以下行在 src/polyfills.ts 中运行良好

/** IE9, IE10, and IE11 require all of the following polyfills. **/

ng --version 的输出

@angular/cli: 1.0.5

节点:6.9.1

操作系统:win32 x64

@angular/common: 4.1.3

@angular/编译器:4.1.3

@angular/core: 4.1.3

@angular/forms: 4.1.3

@angular/http: 4.1.3

@angular/platform-b​​rowser: 4.1.3

@angular/platform-b​​rowser-dynamic: 4.1.3

@angular/路由器:4.1.3

@angular/cli: 1.0.5

@angular/compiler-cli: 4.1.3

【问题讨论】:

  • 在 Chrome 中尝试 settings - additional settings - network/proxy - lan settings - auto-detection
  • 您是否可能使用虚拟机或某种容器运行 chrome?在“localhost”与运行的机器不同的情况下,该消息是有意义的。当然,如果是这样的话,你总是可以ng serve --host 0.0.0.0。但是你仍然需要将浏览器指向运行开发服务器的实际 IP
  • ng serve --host 0.0.0.0 解决了这个问题。

标签: angular google-chrome angular-cli


【解决方案1】:

在我的情况下,项目的路径中有空格,所以我尝试在没有空格的不同路径中创建一个新项目。例如:“C:\Users\Me\Documents”。

注意:我必须在 windows 防火墙中允许 NodeJs。

我希望这些信息有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-06
    • 2017-08-14
    • 1970-01-01
    • 2017-02-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多