"Lite-server 在 Angular 应用中显示空白屏幕"。

20 浏览
0 Comments

"Lite-server 在 Angular 应用中显示空白屏幕"。

我想使用lite-server测试我的Angular应用的移动视图。

这是我的包json:

{
  "name": "myapp",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "dev": "lite-server"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~12.2.0",
    "@angular/cdk": "^12.2.13",
    "@angular/common": "~12.2.0",
    "@angular/compiler": "~12.2.0",
    "@angular/core": "~12.2.0",
    "@angular/forms": "~12.2.0",
    "@angular/material": "^12.2.1",
    "@angular/platform-browser": "~12.2.0",
    "@angular/platform-browser-dynamic": "~12.2.0",
    "@angular/router": "~12.2.0",
    "@ngx-translate/core": "^14.0.0",
    "@ngx-translate/http-loader": "^7.0.0",
    "lodash": "^4.17.21",
    "ngx-page-scroll": "^8.0.0",
    "ngx-page-scroll-core": "^8.0.0",
    "random-words": "^1.1.2",
    "rxjs": "^6.6.7",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~12.2.1",
    "@angular/cli": "^12.2.13",
    "@angular/compiler-cli": "~12.2.0",
    "@types/jasmine": "~3.8.0",
    "@types/node": "^12.11.1",
    "jasmine-core": "~3.8.0",
    "karma": "^6.3.17",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "~1.7.0",
    "lite-server": "^2.6.1",
    "typescript": "~4.3.5"
  }
}

当我使用命令npm run dev运行我的应用时,我只看到有标题的空白屏幕。

我已经尝试先构建应用,然后在dist文件夹中运行,但没有帮助,我在控制台中也看不到任何错误的空白屏幕。

admin 更改状态以发布 2023年5月20日
0
0 Comments

正如您在这里所看到的:

当您安装了lite-server之后,您需要运行以下命令:

lite-server --baseDir="dist/project-name"

其中的project-name即为您的项目名称,它是您主文件夹的名称。

您也可以尝试使用http-server,您可以在这里查看另一个问题,以及来自这里的文档。

0