Angular ng serve 不是本地主机上的托管站点 [英] Angular ng serve is not hosting site on localhost

查看:27
本文介绍了Angular ng serve 不是本地主机上的托管站点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在 CLI 上运行 ng serve 时,我得到以下输出:

When I run ng serve on my CLI, I get the following output:

Angular Live Development Server 正在侦听 localhost:4200,在 http://localhost:4200/上打开浏览器

Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/

但是当我在浏览器中打开 http://localhost:4200/时,什么也没有.

But when I open http://localhost:4200/ in my browser so there is nothing.

有关如何解决此问题的任何建议?

Any advice on how to solve this issue?

这是我的 package.json

{
  "name": "eastlaw",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.1.0",
    "@angular/common": "^6.1.0",
    "@angular/compiler": "^6.1.0",
    "@angular/core": "^6.1.0",
    "@angular/forms": "^6.1.0",
    "@angular/http": "^6.1.0",
    "@angular/platform-browser": "^6.1.0",
    "@angular/platform-browser-dynamic": "^6.1.0",
    "@angular/router": "^6.1.0",
    "core-js": "^2.5.4",
    "rxjs": "6.0.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.7.0",
    "@angular/cli": "~6.1.5",
    "@angular/compiler-cli": "^6.1.0",
    "@angular/language-service": "^6.1.0",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~2.7.2"
  }
}

推荐答案

要调试问题,请尝试以下操作:

To debug the issue try the following :

  • ng serve -o
  • 使用键 baseURL
  • 检查配置文件中提到的默认端口
  • 使用 ng build 命令检查(如果 webpack 正在生成)
  • ng serve --port 8080 --host 0.0.0.0 --disableHostCheck true

如果可能,尝试上传浏览器控制台图像

if possible try to upload browser console image

这篇关于Angular ng serve 不是本地主机上的托管站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆