升级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
相关产品推荐
相关产品推荐

