Angular 4,无法访问该网站

时间:2018-04-01 18:43:49

标签: angular

我在角度4中面临以下问题(在使用ng服务启动服务器之后)。 我正在尝试点击网址http://localhost:4200/,但我收到的网页显示的消息为"此网站无法到达"。

下面是nodejs .npm和angular versions。

    PS E:\MyLearning\Angular4Examples\firstapp> node -v
    v8.11.1
    PS E:\MyLearning\Angular4Examples\firstapp> npm -v
    5.6.0
    PS E:\MyLearning\Angular4Examples\firstapp> ng -v

        _                      _                 ____ _     ___
       / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
      / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
     / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
    /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                   |___/

    Angular CLI: 1.7.3
    Node: 8.11.1
    OS: win32 x64
    Angular: 5.2.9
    ... animations, common, compiler, compiler-cli, core, forms
    ... http, language-service, platform-browser
    ... platform-browser-dynamic, router

    @angular/cli: 1.7.3
    @angular-devkit/build-optimizer: 0.3.2
    @angular-devkit/core: 0.3.2
    @angular-devkit/schematics: 0.3.2
    @ngtools/json-schema: 1.2.0
    @ngtools/webpack: 1.10.2
    @schematics/angular: 0.3.2
    @schematics/package-update: 0.3.2
    typescript: 2.5.3
    webpack: 3.11.0
    PS E:\MyLearning\Angular4Examples\firstapp>

服务器启动步骤:

    PS E:\MyLearning\Angular4Examples\firstapp> ng serve
    ** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
    Date: 2018-04-01T18:32:35.599Z
    Hash: 2879e8bca9cd899f9051
    Time: 12422ms
    chunk {inline} inline.bundle.js (inline) 3.85 kB [entry] [rendered]
    chunk {main} main.bundle.js (main) 18 kB [initial] [rendered]
    chunk {polyfills} polyfills.bundle.js (polyfills) 554 kB [initial] [rendered]
    chunk {styles} styles.bundle.js (styles) 41.5 kB [initial] [rendered]
    chunk {vendor} vendor.bundle.js (vendor) 7.42 MB [initial] [rendered]

    webpack: Compiled successfully.

3 个答案:

答案 0 :(得分:0)

http://127.0.0.1:4200/在工作吗?

如果是,则需要编辑主机文件并添加以下条目: 127.0.0.1本地主机

答案 1 :(得分:0)

我的 vs 代码在 ubuntu 中自动更新后,我也遇到了这个错误。我运行了 sudo apt-get update 并重新启动了我的计算机。对我来说一切都很好。

答案 2 :(得分:-1)

我通过强制刷新来解决了问题。

确保您的地址栏正在使用http。 Chrome浏览器将我重定向到HTTPS。

  • 打开“开发人员工具”面板(CTRL + SHIFT + I)
  • 右键单击重新加载图标。
  • 选择“清空缓存并重新加载”
相关问题