无法调试 Angular 项目,缺少 .Map 文件

Can't Debug Angular Project, Missing .Map Files

我们有一个无法在浏览器开发工具中调试的应用程序,因为我认为它缺少 .map 文件:

为了生成地图,我尝试了所有可以在网上找到的建议,但没有任何效果。最后,我创建了一个新的 Asp.Net Core Angular 项目,这样我就可以将它们并排比较以弄清楚这一点。交换依赖项后,我发现问题是由 package.json:

中的某些内容引起的
{
  "name": "aspnet_angular_test_app",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "build:ssr": "ng run aspnet_angular_test_app:server:dev",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "12.0.3",
    "@angular/common": "12.0.3",
    "@angular/compiler": "12.0.3",
    "@angular/core": "12.0.3",
    "@angular/forms": "12.0.3",
    "@angular/platform-browser": "12.0.3",
    "@angular/platform-browser-dynamic": "12.0.3",
    "@angular/platform-server": "12.0.3",
    "@angular/router": "12.0.3",
    "aspnet-prerendering": "^3.0.1",
    "bootstrap": "^5.0.1",
    "core-js": "^3.13.1",
    "jquery": "^3.6.0",
    "luxon": "^1.28.0",
    "oidc-client": "^1.11.5",
    "popper.js": "^1.16.0",
    "rxjs": "^6.5.3",
    "zone.js": "0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "12.0.3",
    "@angular/cli": "12.0.3",
    "@angular/compiler-cli": "12.0.3",
    "@angular/language-service": "12.0.3",
    "@types/jasmine": "~3.7.7",
    "@types/jasminewd2": "~2.0.9",
    "@types/luxon": "^1.27.1",
    "@types/node": "^14.17.0",
    "codelyzer": "^6.0.2",
    "jasmine-core": "~3.7.1",
    "jasmine-spec-reporter": "~7.0.0",
    "karma": "^6.3.3",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.3",
    "karma-jasmine": "~4.0.1",
    "karma-jasmine-html-reporter": "^1.6.0",
    "typescript": "4.2.3"
  },
  "optionalDependencies": {
    "protractor": "~7.0.0",
    "sass": "~1.34.0",
    "ts-node": "~10.0.0",
    "tslint": "^6.1.0"
  }
}

请问如何解决?我试过调整套餐,但我似乎无处可去。

您在开始项目调试时,浏览器是否出现如下错误:

这是没有安装npm模块。

请运行npm install安装节点模块。

官方文档:https://docs.microsoft.com/en-us/aspnet/core/client-side/spa/angular?view=aspnetcore-5.0&tabs=visual-studio

花了我很长时间,但我了解到问题是由

引起的
"@angular-devkit/build-angular": "12.0.3"

当我切换到

"@angular-devkit/build-angular": "^0.1002.3"

它似乎工作正常。

更新: 我相信这个问题来自升级到 Angular 12。我已经将同一个应用程序升级到 12.2.13(包括@angular-devkit/build-angular),但肯定会添加一个开发环境,因为 Angular 12默认使用 'production' 配置。这是帮助我解决问题的 link: