You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular 14生成组件报错:Data path不允许含standalone属性

Angular 14生成组件报错:Data path "" must NOT have additional properties(standalone)

错误信息

执行组件生成命令时触发以下验证错误:

Schematic input does not validate against the Schema: {"style":"css","name":"kdsf","path":"src/app/talentManager","project":"Belbio","displayBlock":false,"inlineStyle":false,"inlineTemplate":false,"standalone":false,"changeDetection":"Default","type":"Component","skipTests":true,"flat":false,"skipImport":false,"skipSelector":false,"export":false}
Errors:
Data path "" must NOT have additional properties(standalone).

问题原因

从项目的package.json依赖可以看出:

  • @angular/cli版本为14.2.10(Angular 14版本)
  • @schematics/angular版本为13.3.10(Angular 13版本)

两者版本不匹配导致:Angular 14的CLI会自动向组件生成 schematic 传递standalone参数,但Angular 13的@schematics/angular不支持该参数,触发Schema验证失败。

解决方案

方案1:升级@schematics/angular到匹配版本

执行以下命令将@schematics/angular升级到与Angular CLI一致的14.x版本:

npm install @schematics/angular@^14.2.10 --save-dev

方案2:生成组件时显式禁用standalone参数

如果暂时不想升级依赖,可以在生成组件时添加--no-standalone参数,避免传递该属性:

ng generate component talentManager/kdsf --no-standalone --skip-tests

额外优化(可选)

检查angular.json中的CLI配置,确保@schematics/angular在schematicCollections中优先级最高,避免其他 schematic 干扰:

"cli": {
  "analytics": "4f69cedd-fdcb-413e-aa01-c300888f149f",
  "schematicCollections": ["@schematics/angular", "@cypress/schematic", "@angular-eslint/schematics"]
}

内容的提问来源于stack exchange,提问作者ahmad eid

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 11:56:36