在我的Angular 应用程序中,它没有正确显示错误。它总是在main.js中显示错误,而不是像在其他Angular 应用程序中那样显示组件和行号。请检查此screenshot
这是我的angular.json。看起来它缺少开发配置。
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"cli": {
"analytics": "fadcd178-4e22-400b-975d-788758cb58bf"
},
"version": 1,
"newProjectRoot": "projects",
"projects": {
"route-app": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
},
"@schematics/angular:application": {
"strict": true
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/route-app",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": ["src/favicon.ico", "src/assets"],
"styles": [
"src/styles.scss",
"node_modules/leaflet/dist/leaflet.css",
"node_modules/leaflet.markercluster/dist/MarkerCluster.Default.css",
"src/app/themes/styles/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "2mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "5kb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "route-app:build"
},
"configurations": {
"production": {
"browserTarget": "route-app:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "route-app:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": ["src/favicon.ico", "src/assets"],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"../node_modules/ngx-simple-modal/styles/simple-modal.css",
"src/styles.scss"
],
"scripts": []
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json",
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": ["**/node_modules/**"]
}
},
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "route-app:serve"
},
"configurations": {
"production": {
"devServerTarget": "route-app:serve:production"
}
}
}
}
}
},
"defaultProject": "route-app"
}
这是我的packages.json
{
"name": "route-app",
"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": {
}
}
请帮帮忙。
谢谢你
2条答案
按热度按时间oyjwcjzk1#
添加如下开发配置。
然后使用
ng serve -c development
启动您的应用。t40tm48m2#
angular.json文件中的配置应该为您正在使用的环境启用源Map,例如,Map“dev”环境中的错误:
如果没有“sourceMap”:true,则错误不会被跟踪到特定的源文件。此参数可以被赋值为布尔值或对象,但“true”应该足以解决您的问题,如官方文档中所述:
https://angular.io/guide/workspace-config#source-map-configuration