0

我使用此处提供的角度更新指南https://angular.io/guide/update-to-latest-version将我的角度项目从 12 升级到 13,没有任何问题。但是,当使用“ng serve --open”命令在我的本地机器(mac)上运行项目时,它会提示浏览器下载窗口,而不是运行项目。我注意到没有编译错误并且 ng build 成功。我尝试删除并重新安装节点模块,但问题仍然存在。这是我的 package.json 文件。任何线索都受到高度赞赏。谢谢。

{
  "name": "dashboard-new11",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^13.1.3",
    "@angular/common": "^13.1.3",
    "@angular/compiler": "^13.1.3",
    "@angular/compiler-cli": "^13.1.3",
    "@angular/core": "^13.1.3",
    "@angular/forms": "^13.1.3",
    "@angular/platform-browser": "^13.1.3",
    "@angular/platform-browser-dynamic": "^13.1.3",
    "@angular/platform-server": "^13.1.3",
    "@angular/router": "^13.1.3",
    "@types/file-saver": "^2.0.1",
    "@types/jest": "^26.0.4",
    "angular-webstorage-service": "^1.0.2",
    "angular2-toaster": "^11.0.1",
    "core-js": "^2.4.1",
    "ngx-bootstrap": "^7.1.2",
    "ngx-webstorage-service": "^4.1.0",
    "node": "^14.15.1",
    "pako": "^1.0.11",
    "rxjs": "^6.6.7",
    "rxjs-compat": "^6.5.2",
    "tslib": "^2.0.0",
    "typescript": "4.5.4",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~13.1.4",
    "@angular/cli": "^13.1.4",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "file-saver": "^2.0.5",
    "karma": "~6.3.9",
    "karma-chrome-launcher": "~3.1.0",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "ng-autosize": "^1.1.0",
    "protractor": "~7.0.0",
    "schematics-scss-migrate": "^1.3.14",
    "ts-node": "~2.0.0",
    "tslint": "~6.1.3"
  }
}

这是启动日志

✔ Browser application bundle generation complete.

Initial Chunk Files   | Names         |  Raw Size
vendor.js             | vendor        |   4.58 MB | 
main.js               | main          |   1.88 MB | 
polyfills.js          | polyfills     | 386.86 kB | 
styles.css, styles.js | styles        | 260.59 kB | 
runtime.js            | runtime       |   6.86 kB | 

                      | Initial Total |   7.10 MB

Build at: 2022-01-20T07:38:36.218Z - Hash: e641c46fc4de7304 - Time: 17292ms

Warning: /Users/TSC/Desktop/Watson360/Backups/Advisor360-UI-Angular13/client/src/app/shared/app.http.service.ts depends on 'pako'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: /Users/TSC/Desktop/Watson360/Backups/Advisor360-UI-Angular13/client/src/app/shared/app.messenger.service.ts depends on 'rxjs/Rx'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies



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


✔ Compiled successfully.
4

1 回答 1

0

升级到 Angular 13 后,我也遇到了同样的问题。

请验证构建选项部分中的 angular.json 文件中的内容。在那里你应该找到以下内容:

"index": "src/index.html",

几年前我曾经将其更改为“index.aspx”,因为我在 SharePoint 中做一个大型企业应用程序,但现在这导致我有你描述的行为。

于 2022-01-21T13:23:10.867 回答