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

升级Angular15与NX16时遭遇angular.json v2格式不支持问题

Angular 15 + Nx 16升级后angular.json格式错误问题解决

升级Angular(v15)和Nx(v16)后启动项目,Nx抛出如下错误:

NX angular.json format is incorrect

Nx no longer supports the v2 format of angular.json.
Run "nx g @nx/workspace:fix-configuration" to split angular.json into individual project.json files. (Recommended)
If you want to preserve angular.json, run "nx g @nx/workspace:fix-configuration --reformat"

但项目已提前拆分为project.json文件,执行上述两条命令虽显示成功,却没有任何文件更新。当前angular.json内容如下:

{
  "$schema": "./node_modules/nx/schemas/workspace-schema.json",
  "version": 2,
  "projects": {
    "xxx": "libs/xxx",
    "xxx-e2e": "apps/xxx-e2e",
    "yyy": "libs/yyy",
    "yyy-e2e": "apps/yyy-e2e"
  }
}

各项目下的project.json结构示例:

{
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
  "name": "xxx-e2e",
  // Either the e2e schema
  // or the library schema
}

解决步骤

  • 直接编辑根目录的angular.json文件,将"version": 2修改为"version": 1
  • 保存文件后重新启动项目,格式错误提示即可消失
  • 可选验证:执行命令 nx show projects,确认所有项目都能被Nx正常识别

内容的提问来源于stack exchange,提问作者Get Off My Lawn

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.12 01:37:12