6

While trying to run my application built in angular 13 throwing below error. Don't know the reason for this. Any help would be appreciated.

Error:

"[error] Error: [readCachedProjectGraph] ERROR: No cached ProjectGraph is available.

If you are leveraging \`readCachedProjectGraph()\` directly then you will need to refactor your usage to first ensure that
the ProjectGraph is created by calling \`await createProjectGraphAsync()\` somewhere before attempting to read the data.

If you encounter this error as part of running standard \`nx\` commands then please open an issue on https://github.com/nrwl/nx

Make sure invoke 'node ./decorate-angular-cli.js' in your postinstall script.
The decorated CLI will compute the project graph.
'ng --help' should say 'Smart, Fast and Extensible Build System'.
    at readCachedProjectGraph (C:\Project\xxxx\node_modules\nx\src\project-graph\project-graph.js:28:15)
    at calculateResolveMappings (C:\Project\xxxxx\node_modules\@nrwl\node\src\executors\node\node.impl.js:57:62)
    at nodeExecutor_1 (C:\Project\xxxxx\node_modules\@nrwl\node\src\executors\node\node.impl.js:34:26)
    at nodeExecutor_1.next (<anonymous>)
    at resume (C:\Project\xxxxx\node_modules\tslib\tslib.js:230:48)
    at C:\Project\xxxxx\node_modules\tslib\tslib.js:229:125
    at new Promise (<anonymous>)
    at Object.i.<computed> [as next] (C:\Project\xxxxx\node_modules\tslib\tslib.js:229:67)
    at recurse (C:\Project\xxxxx\node_modules\@nrwl\devkit\src\utils\convert-nx-executor.js:44:22)
    at Observable._subscribe (C:\Project\xxxxx\node_modules\@nrwl\devkit\src\utils\convert-nx-executor.js:61:13)"
Rahul Jha
  • 874
  • 1
  • 11
  • 28
  • Quick solution to this problem is to try adding decorate-angular-cli.js on root folder and run the postinstall script. Cheers! – Rahul Jha Feb 21 '23 at 15:31

1 Answers1

1

For me, this was caused by a missing NX cache directory.

I had this error in a Gitlab pipeline and resolved it by adding a small postinstall script to make sure it gets created.

{
  "scripts": {
    "postinstall": "mkdir -p .nx"
  }
}
blid
  • 971
  • 13
  • 22