angularnpmnestjsmonoreponpx

Nx can't create project graph (projects in the following directories have no name provided)


I'm trying to create a monorepo for a project that uses angular and nestjs for a techstack. I used this command to initialize the repo.

npx create-nx-workspace@latest university_archive --preset=angular I have also tried

npx create-nx-workspace@latest university_archive --preset=nest

Immediately after successful build I try to run nx graph but get the error

 NX   Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it. See errors below.

Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
  ProjectsWithNoNameError: The projects in the following directories have no name provided:
    - apps/university_archive-e2e
      at validateAndNormalizeProjectRootMap (/home/xx/xx/xx/xx/xx/xx-xx/university_archive/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:439:15)
      at mergeCreateNodesResults (/home/xx/xx/xx/xx/xx/xx-xx/university_archive/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:322:9)
      at /home/xx/xx/xx/xx/xx/xx-xx/university_archive/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:267:85
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async processFilesAndCreateAndSerializeProjectGraph (/home/xx/xx/xx/xx/xx/xx-xx/university_archive/node_modules/nx/src/daemon/server/project-graph-incremental-recomputation.js:148:43)
      at async getCachedSerializedProjectGraphPromise (/home/xx/xx/xx/xx/xx/xx-xx/university_archive/node_modules/nx/src/daemon/server/project-graph-incremental-recomputation.js:48:16)
      at async handleRequestProjectGraph (/home/xx/xx/2024/xx/xx/xx-xx/university_archive/node_modules/nx/src/daemon/server/handle-request-project-graph.js:12:24)
      at async handleResult (/home/xx/xx/xxx/xx/xx/xx-xx/university_archive/node_modules/nx/src/daemon/server/server.js:140:16)
      at async handleMessage (/xx/xx/xx/xx/xx/xx/xx-xx/university_archive/node_modules/nx/src/daemon/server/server.js:93:9)
      at async /xx/xx/xx/xx/xx/xx/xx-xx/university_archive/node_modules/nx/src/daemon/server/server.js:59:9

I have double, triple checked that the name in project.json does correspond.(please don't suggest that as a solution). I have reset nx multiple times, as root even. So please don't suggest that either

This is the contents of project.json in university_archive-e2e, as generated by npx.

{
  "name": "university_archive-e2e",
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
  "projectType": "application",
  "sourceRoot": "apps/university_archive-e2e/src",
  "tags": [],
  "implicitDependencies": ["university_archive"],
  "// targets": "to see all targets run: nx show project university_archive-e2e --web",
  "targets": {}
}

This is my project structure:

-university_archive
---apps
-----university_archive
--------project.json
--------src
--------other files etc..
-----university_archive-e2e
--------src
--------project.json
--------other files etc...
---package.json
---node_modules
---.nx
---nx.json

Im using

The issue seems related to this on github issue

I Have tried their suggestions but they dont work :(

I have re-built/re-done the project creation more times than I can count. I Tried gpt, claude and gemini This is my last hope...


Solution

  • I found the problem and how to solve it. :) (Afters hours of debugging)

    In my repo there was a .gitignore file that contained

    *.json
    

    When removing that *.json from the .gitignore the graph could build. When putting it back it broke again.

    I assume that it for some reason couldn't read the json configuration files when it was listed in the .gitignore. And since it couldn't build the graph, nothing else worked.

    Nonetheless removing

    *.json
    

    Solved the problem. Hope this helps someone in the future...