[英]An unhandled exception occurred: error TS5024: Compiler option 'sourceMap' requires a value of type boolean
I am updating my angular code version from 4.0.0 to latest.我正在将我的 angular 代码版本从 4.0.0 更新到最新版本。 Instead of updating it all together from version 4.0.0 to 9.1.2, as a recommendation I tried doing it to version 6.0.0 first and then to 8.0.0 and finally to version 9.1.2.作为建议,我没有将它从 4.0.0 版本一起更新到 9.1.2,而是尝试先更新到 6.0.0 版本,然后再更新到 8.0.0,最后更新到 9.1.2 版本。 But while doing so following this link I first tried doing it to version 6.0.0.但是在按照此链接进行操作时,我首先尝试对 6.0.0 版本进行操作。 But somehow it updated packages to latest versions directly.但不知何故,它直接将软件包更新到最新版本。 Now while running the command 'npm start' I am facing following issue:现在在运行命令“npm start”时,我面临以下问题:
An unhandled exception occurred: error TS5024: Compiler option 'sourceMap' requires a value of type boolean.发生未处理的异常:错误 TS5024:编译器选项“sourceMap”需要 boolean 类型的值。
and following error for ng serve command: ng serve 命令出现以下错误:
Schema validation failed with the following errors: Data path "" should have required property 'browserTarget'.架构验证失败并出现以下错误:数据路径“”应该具有必需的属性“browserTarget”。
angular.json angular.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"sitc-web-app": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/favicon.ico"
],
"styles": [
"src/assets/SHUI/shui-styles.css",
"src/styles.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"src/assets/SH-HTML-CSS-LIBRARY/js/bundle.min.js",
"src/assets/SH-HTML-CSS-LIBRARY/js/polyfills.min.js",
"src/assets/SH-HTML-CSS-LIBRARY/js/vendors.min.js",
"src/assets/SHUI/shui.min.js"
]
},
"configurations": {
"local": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.ts"
}
]
},
"dev": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.dev.ts"
}
]
},
"staging": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.staging.ts"
}
]
},
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"local": {
"browserTarget": "sitc-web-app:build"
},
"dev": {
"browserTarget": "sitc-web-app:build:dev"
},
"staging": {
"browserTarget": "sitc-web-app:build:staging"
},
"production": {
"browserTarget": "sitc-web-app:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "sitc-web-app:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"src/assets/SH-HTML-CSS-LIBRARY/js/bundle.min.js",
"src/assets/SH-HTML-CSS-LIBRARY/js/polyfills.min.js",
"src/assets/SH-HTML-CSS-LIBRARY/js/vendors.min.js",
"src/assets/SHUI/shui.min.js"
],
"styles": [
"src/assets/SHUI/shui-styles.css",
"src/styles.css"
],
"assets": [
"src/assets",
"src/favicon.ico"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"sitc-web-app-e2e": {
"root": "",
"sourceRoot": "",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "sitc-web-app:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "sitc-web-app",
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"styleext": "css"
},
"@schematics/angular:directive": {
"prefix": "app"
}
}
}
I separately added the 'local' part inside 'serve->configurations' and 'configurations' as I am running my code in local environment also.我在“服务->配置”和“配置”中分别添加了“本地”部分,因为我也在本地环境中运行我的代码。
package.json package.json
{
"name": "abc-web-app",
"version": "0.0.0",
"license": "XYZ",
"scripts": {
"ng": "ng",
"start": "ng serve -o --configuration=local",
"build-dev": "ng build --prod --configuration=dev --output-path=dist/dev",
"build-staging": "ng build --prod --configuration=staging --output-path=dist/staging",
"build-prod": "ng build --prod --configuration=prod --output-path=dist/prod",
"build": "npm-run-all -p build-dev build-staging build-prod",
"local-build-dev": "npm run build-dev && deleteAndCopy.bat dev",
"local-build-staging": "npm run build-staging && deleteAndCopy.bat staging",
"local-build-prod": "npm run build-prod && deleteAndCopy.bat prod",
"local-build-all": "npm run local-build-dev && npm run local-build-staging && npm run local-build-prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^9.1.9",
"@angular/common": "^9.1.9",
"@angular/compiler": "^9.1.9",
"@angular/core": "^9.1.9",
"@angular/forms": "^9.1.9",
"@angular/http": "^7.2.16",
"@angular/platform-browser": "^9.1.9",
"@angular/platform-browser-dynamic": "^9.1.9",
"@angular/router": "^9.1.9",
"angular2-csv": "^0.2.9",
"auth0-js": "^9.13.2",
"classlist.js": "^1.1.20150312",
"core-js": "^3.6.5",
"font-awesome": "^4.7.0",
"jquery": "^3.5.1",
"jquery-datetimepicker": "^2.5.21",
"jwt-decode": "^2.2.0",
"rxjs": "^6.5.5",
"web-animations-js": "^2.3.2",
"xml2js": "^0.4.23",
"zone.js": "^0.10.3"
},
"devDependencies": {
"@angular/cli": "9.1.7",
"@angular/compiler-cli": "^9.1.9",
"@types/auth0-js": "^9.13.1",
"@types/jasmine": "~3.5.10",
"@types/jasminewd2": "~2.0.8",
"@types/jquery": "^3.3.38",
"@types/jwt-decode": "^2.2.1",
"@types/node": "~14.0.6",
"codelyzer": "^5.2.2",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~5.0.2",
"karma": "~5.0.9",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "^3.0.3",
"karma-jasmine": "~3.3.1",
"karma-jasmine-html-reporter": "^1.5.4",
"npm-run-all": "^4.1.5",
"protractor": "~7.0.0",
"ts-node": "~8.10.2",
"tslint": "~6.1.2",
"typescript": "3.9.3",
"@angular-devkit/build-angular": "~0.901.7"
}
}
tsconfig.json tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": ["node_modules/@types"],
"lib": ["es2017", "dom"],
"baseUrl": "src",
"paths": {
"@abc/models/*": ["app/models/*", "app/modules/booking-portal/models/*", "app/modules/training-portal/models/*"],
"@abc/constants": ["app/constants"]
}
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"preserveWhitespaces": false
}
}
Kindly help.请帮忙。 Any help towards a solution regarding this is highly appreciated.对此解决方案的任何帮助都将受到高度赞赏。 Thanks in advance.提前致谢。
Solved it.解决了。 In tsconfig.app.json file looked like:-在 tsconfig.app.json 文件中看起来像:-
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"sourceMap": "true",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
updated souceMap value to true instead of "true" .将souceMap值更新为true而不是"true" 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.