javascriptangularnrwl-nxnrwl

Nx no longer supports the v2 format of angular.json


I am trying to upgrade angular (v15) and nx (v16) in my project, but the issue that I am running into is when I start my project NX throws an error:

 >  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"

Which is confusing to me, as my project is already split into project.json files. I did try to run the two suggested commands, it succeeds, but no files get updated...

Here is my angular.json file which looks like it is the correct format:

{
  "$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"
  }
}

Then, I have the project.json where each one looks like this (where xxx is the project and some contain -e2e and others don't depending on if the project is an e2e application or a library):

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

Solution

  • What solved the issue for me, was just removing the angular.json, as NX no longer uses the angular.json file. The data is stored in the project.json, and NX seems to load all of the project.json files (probably using a glob).

    So, my solution: Delete (or rename) the angular.json.