将应用程序从5号角迁移到6号角后,运行ng时会弹出以下错误消息。
架构验证失败,出现以下错误: 数据路径“”不应具有其他属性(项目)。 错误:架构验证失败,出现以下错误: 数据路径“”不应具有其他属性(项目)。 在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.next(/home/training/Attinad_Projects/TemplateApp/me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:64:18) 在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/InnerSubscriber.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.Subscriber.next(/.../me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/Subscriber.js:64:18) 在SwitchMapSubscriber.notifyNext(... / me-cmf-web-template-angular/node_modules/@angular-devkit/core/node_modules/rxjs/internal/operators/switchMap.js:77:26)
我假设错误与.angular.json文件有关,该文件是从.angular-cli.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文件吗?
任何帮助都会很棒。
答案 0 :(得分:10)
当我遇到版本错误问题时,以下命令对我有用:
首次运行:
npm update
第二次运行:
ng update
第三次运行: (它将更新所有不匹配的软件包)
ng update --all --force
答案 1 :(得分:6)
问题通常是由于您的package.json
文件中的版本不匹配。
在Angular 7应用中,我已将"@angular-devkit/build-angular": "^0.800.2"
更改为"@angular-devkit/build-angular": "~0.7.0"
。
然后,我在删除npm install
后运行命令mode_modules
。
答案 2 :(得分:6)
第一:
npm uninstall @angular-devkit/build-angular
下一步:
npm install @angular-devkit/build-angular@0.12.4
答案 3 :(得分:2)
从9到10的角度升级非常容易(所有其他详细信息在这里:https://update.angular.io/?v=9.0-10.0):
确保您的软件包文件处于版本控制中,并且所有更改均已提交。这将覆盖您的软件包文件。最好您在新的实验分支中尝试一下。
npm install -g npm-check-updates
ncu -u
ng update --all --force
在新架构中,不再允许使用键es5BrowserSupport
,请在angular.json
中删除以下行:
"es5BrowserSupport": true
然后简单地重新启动应用程序:
npm start
答案 4 :(得分:1)
我认为是RxJS
的不兼容。您应该安装rxjs-compat
来解决此问题。
npm install rxjs-compat
此外,文件名是angular.json
而不是.angular.json
答案 5 :(得分:1)
angular.json 的格式必须与Angular6相同...您可以在下面检查我的angular.json或在Angular6中创建一个新项目,然后检查“ project”的格式头
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"homePage6": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/homePage6",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets",
"src/manifest.json"
],
"styles": [
"src/styles.scss"
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"serviceWorker": true
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "homePage6:build"
},
"configurations": {
"production": {
"browserTarget": "homePage6:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "homePage6:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"styles.scss"
],
"scripts": [],
"assets": [
"src/favicon.ico",
"src/assets",
"src/manifest.json"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"homePage6-e2e": {
"root": "e2e/",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "homePage6:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "homePage6"
}
我遇到了类似的问题(不完全相同,但在angular.json中也是如此)
架构验证失败,出现以下错误:数据路径 “ ['server']”不应具有其他属性(脚本)。错误: 架构验证失败,出现以下错误:数据路径 “ ['server']”不应具有其他属性(脚本)。 在MergeMapSubscriber._registry.compile.pipe.operators_1.concatMap.validatorResult中 [作为项目] (D:\ Angular7 \ uHome \ node_modules @ angular-devkit \ core \ src \ workspace \ workspace.js:215:42) 在MergeMapSubscriber._tryNext(D:\ Angular7 \ uHome \ node_modules \ rxjs \ internal \ operators \ mergeMap.js:69:27) 在MergeMapSubscriber._next(D:\ Angular7 \ uHome \ node_modules \ rxjs \ internal \ operators \ mergeMap.js:59:18) 在MergeMapSubscriber.Subscriber.next(D:\ Angular7 \ uHome \ node_modules \ rxjs \ internal \ Subscriber.js:67:18) 在MergeMapSubscriber.notifyNext(D:\ Angular7 \ uHome \ node_modules \ rxjs \ internal \ operators \ mergeMap.js:92:26) 在InnerSubscriber._next(D:\ Angular7 \ uHome \ node_modules \ rxjs \ internal \ InnerSubscriber.js:28:21) 在InnerSubscriber.Subscriber.next(D:\ Angular7 \ uHome \ node_modules \ rxjs \ internal \ Subscriber.js:67:18) 在MapSubscriber._next(D:\ Angular7 \ uHome \ node_modules \ rxjs \ internal \ operators \ map.js:55:26) 在MapSubscriber.Subscriber.next(D:\ Angular7 \ uHome \ node_modules \ rxjs \ internal \ Subscriber.js:67:18) 在SwitchMapSubscriber.notifyNext(D:\ Angular7 \ uHome \ node_modules \ rxjs \ internal \ operators \ switchMap.js:86:26)
必须从我的angular.json中删除属性脚本...共享此信息以在将来帮助某人。
答案 6 :(得分:1)
自从我解决了这个问题以来,我认为将其发布在这里会很好。
我将文件名.angular.json更改为angular.json,并替换了其中问题的某些属性。
{
"$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"template-appv6": {
"root": "",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/browser",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
{
"glob": "**/*",
"input": "src/assets",
"output": "/assets"
},
{
"glob": "favicon.ico",
"input": "src",
"output": "/"
}
],
"styles": [
"src/styles.scss"
],
"scripts": []
},
"configurations": {
"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",
"options": {
"browserTarget": "template-appv6:build"
},
"configurations": {
"production": {
"browserTarget": "template-appv6:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "template-appv6: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": [],
"styles": [
"src/styles.css"
],
"assets": [
{
"glob": "**/*",
"input": "src/assets",
"output": "/assets"
},
{
"glob": "favicon.ico",
"input": "src",
"output": "/"
}
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist/server",
"main": "src/main.server.ts",
"tsConfig": "src/tsconfig.server.json"
}
}
}
},
"template-appv6-e2e": {
"root": "",
"projectType": "application",
"cli": {},
"schematics": {},
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "template-appv6:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"cli": {},
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"styleext": "css"
},
"@schematics/angular:directive": {
"prefix": "app"
}
}
}
我通过用angular官方文档中的属性替换angular.json文件来更改了文件。
官方Angular Update Guide提供了有关如何更新版本的逐步指南。
答案 7 :(得分:0)
将package.json
从以下位置更改:
"@angular-devkit/build-angular": "^0.13.5",
收件人:
"@angular-devkit/build-angular": "^0.12.1",
答案 8 :(得分:0)
更新npm
和angular
固定的地雷:
假设您使用npm
npm update
然后运行:
ng update
NB:可能会提示您更新各个依赖项。就我而言,系统提示我运行:
ng update @angular/cli
和ng update @angular/core
。
答案 9 :(得分:0)
我的应用程序位于角7.2.3上
从“ angular.json”中删除“ es5BrowserSupport”:true。 和npm start现在可以工作了。
答案 10 :(得分:0)
转到package.json
并按如下所示更改 @ angular-devkit / build-angular 的版本:
@angular-devkit/build-angular": "^0.12.4"
答案 11 :(得分:0)
我刚刚删除了 node_module 文件夹并运行
NPM安装
对我来说很好。
这是 Angular 9 解决方案。
答案 12 :(得分:0)
将Angular
从版本10
升级到8
时,我遇到了非常相似的错误,即Schema validation failed with the following errors: Data path "" should NOT have additional properties(serverTarget).
。
解决方案是从"serverTarget"
下面移除所有"serve"
引用。以下是错误:
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "my_app:build"
"serverTarget": "my_app:server"
},
"configurations": {
"production": {
"browserTarget": "my_app:build:production",
"serverTarget": "my_app:server:production"
}
}
},
以下内容正确并且编译成功:
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "my_app:build"
},
"configurations": {
"production": {
"browserTarget": "my_app:build:production"
}
}
},
奖金(针对与Angular Universal
合作的人)。如果要在localhost
上运行SSR,则确实需要serverTarget
。但是,为此,您必须在angular.json
内创建一个新部分,例如:
"serve-ssr": {
"builder": "@nguniversal/builders:ssr-dev-server",
"options": {
"browserTarget": "my_app:build",
"serverTarget": "my_app:server"
},
"configurations": {
"production": {
"browserTarget": "my_app:build:production",
"serverTarget": "my_app:server:production"
}
}
},
然后ng run my_app:serve-ssr
。
实际上,当将Angular
从版本10
升级到8
时出现了此错误,并希望进行一些改进。然后,我用错误的思想弄乱了serverTarget
的事情,希望这对一个项目中有Angular Universal
的人有所帮助。
答案 13 :(得分:0)
从angular.json文件中删除这两行:
"vendorSourceMap":"true",
"evalSourceMap":"true".
答案 14 :(得分:0)
ani.save('files/animation.gif',writer='imagemagick', fps=60)
移除标志 es5BrowserSupport: true
解决了问题。因为我是从 angular.json
更新到 Angular7
,所以我跳过了 https://update.angular.io/ 升级指南中的一点。
Angular11
并设置您的 es5BrowserSupport flags in your angular.json
。 Angular 现在使用您的浏览器列表来确定是否需要 ES5 构建。 ng update 将自动迁移您。