将应用程序从 angular 5 迁移到 6 后,在运行 ng serve 时会弹出以下错误。
架构验证失败并出现以下错误:数据路径“”不应有其他属性(项目)。错误:架构验证失败并出现以下错误:数据路径“”不应具有其他属性(项目)。在 MergeMapSubscriber._registry.compile.pipe.operators_1.concatMap.validatorResult [作为项目] (…/TemplateApp/me-cmf-web-template-angular/node_modules/@angular-devkit/core/src/workspace/workspace. js:210:42) 在 MergeMapSubscriber._tryNext (/…/me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:65:27 ) 在 MergeMapSubscriber._next (…/me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:55:18) 在 MergeMapSubscriber.Subscriber。在 MergeMapSubscriber.notifyNext (. ../TemplateApp/me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/mergeMap.js:84:26) 在 InnerSubscriber._next (…/me -cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Inne rSubscriber.js:25:21) 在 InnerSubscriber.Subscriber.next (/…/me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:64 :18) 在 MapSubscriber._next (…/me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/map.js:52:26) 在 MapSubscriber。 SwitchMapSubscriber.notifyNext (… /me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/switchMap.js:77:26)
我假设错误与我从 .angular-cli.json 重命名的 .angular.json 文件有关。
我的 .angular.json 文件如下:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "mediaweb"
},
"apps": [{
"root": "src",
"outDir": "dist/browser",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.scss",
"../node_modules/owl.carousel/dist/assets/owl.carousel.css",
"../node_modules/owl.carousel/dist/assets/owl.theme.default.css",
"../node_modules/video.js/dist/video-js.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/owl.carousel/dist/owl.carousel.js",
"../node_modules/video.js/dist/ie8/videojs-ie8.js",
"../node_modules/video.js/dist/video.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.dev.ts",
"prod": "environments/environment.prod.ts"
}
},
{
"platform": "server",
"root": "src",
"outDir": "dist/server",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.server.ts",
"test": "test.ts",
"tsconfig": "tsconfig.server.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.scss"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.dev.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [{
"project": "src/tsconfig.app.json",
"exclude": ["**/node_modules/**", "**/UI/**"]
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "scss",
"component": {}
}
}
我应该重新构造 json 文件吗,如果是这样的话?
任何帮助都会很棒。
原文由 V5NEXT 发布,翻译遵循 CC BY-SA 4.0 许可协议
既然我解决了这个问题,我认为把它贴在这里会很好。
我将文件名 .angular.json 更改为 angular.json 并替换了其中问题的一些属性。
我通过用 angular 官方文档中的属性替换 angular.json 文件来更改文件。
官方 Angular 更新指南 提供了有关如何更新版本的分步指南。