question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error reading nxdeps.json

See original GitHub issue

Current Behavior

While running some commands in parallel we receive the following error:

Error reading '/home/circleci/project/repo/node_modules/.cache/nx/nxdeps.json'. Continue the process without the cache.
Error: ValueExpected in /home/circleci/project/repo/node_modules/.cache/nx/nxdeps.json at position 0
    at parseJson (/home/circleci/project/repo/node_modules/@nrwl/tao/src/utils/json.js:30:15)
    at readJsonFile (/home/circleci/project/repo/node_modules/@nrwl/tao/src/utils/fileutils.js:21:37)
    at readCache (/home/circleci/project/repo/node_modules/@nrwl/workspace/src/core/nx-deps/nx-deps-cache.js:41:46)
    at Object.readCachedProjectGraph (/home/circleci/project/repo/node_modules/@nrwl/workspace/src/core/project-graph/project-graph.js:19:61)
    at jestExecutor2 (/home/circleci/project/repo/node_modules/@*******org/nx-jest/src/executors/jest/jest.impl.js:107:46)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
[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.

(Note: we are using a jest executor that wraps the Nrwl Nx Jest executor to modify the jest config, doesn’t do anything with Nx itself, can find the code here, https://github.com/trellisorg/platform/tree/master/packages/nx-jest, it shouldn’t have anything to do with it.)

We have 3 e2e test suites (that actually just use jest) for our API, each of them has a dependsOn target:

"dependsOn": [
  { "target": "build", "projects": "dependencies" }
]

So that all dependencies of these e2e test suites (which are just node projects in the apps folder) are built (or pulled from cache) prior to running the e2e tests.

Then we run

yarn nx affected --target feature-e2e

and receive the error (not every time though)

Expected Behavior

Should not error and running commands in parallel should work fine.

Steps to Reproduce

This issue may not be prioritized if details are not provided to help us reproduce the issue.

Failure Logs

Error reading '/home/circleci/project/repo/node_modules/.cache/nx/nxdeps.json'. Continue the process without the cache.
Error: ValueExpected in /home/circleci/project/repo/node_modules/.cache/nx/nxdeps.json at position 0
    at parseJson (/home/circleci/project/repo/node_modules/@nrwl/tao/src/utils/json.js:30:15)
    at readJsonFile (/home/circleci/project/repo/node_modules/@nrwl/tao/src/utils/fileutils.js:21:37)
    at readCache (/home/circleci/project/repo/node_modules/@nrwl/workspace/src/core/nx-deps/nx-deps-cache.js:41:46)
    at Object.readCachedProjectGraph (/home/circleci/project/repo/node_modules/@nrwl/workspace/src/core/project-graph/project-graph.js:19:61)
    at jestExecutor2 (/home/circleci/project/repo/node_modules/@*******org/nx-jest/src/executors/jest/jest.impl.js:107:46)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
[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

Environment

 >  NX   Report complete - copy this into the issue template

   Node : 12.22.7
   OS   : darwin x64
   yarn : 1.22.17
   
   nx : 13.8.3
   @nrwl/angular : 13.8.3
   @nrwl/cli : 13.8.3
   @nrwl/cypress : 13.8.3
   @nrwl/detox : undefined
   @nrwl/devkit : 13.8.3
   @nrwl/eslint-plugin-nx : 13.8.3
   @nrwl/express : 13.8.3
   @nrwl/jest : 13.8.3
   @nrwl/js : 13.8.3
   @nrwl/linter : 13.8.3
   @nrwl/nest : 13.8.3
   @nrwl/next : undefined
   @nrwl/node : 13.8.3
   @nrwl/nx-cloud : 13.1.5
   @nrwl/react : undefined
   @nrwl/react-native : undefined
   @nrwl/schematics : undefined
   @nrwl/storybook : 13.8.3
   @nrwl/tao : 13.8.3
   @nrwl/web : 13.8.3
   @nrwl/workspace : 13.8.3
   typescript : 4.5.5
   rxjs : 7.4.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:33
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

10reactions
wSedlacekcommented, Aug 15, 2022

I noticed that the writeCache() is getting called over and over again just writing the same data that is already there every time the graph is read. Adding a simple check to see if the data it is writing is already what is there should reduce the chances that it is in the middle of writing when reading starts.

9reactions
sorin-davidoicommented, Mar 16, 2022

Can someone on the NX team weigh in on this (e.g. what solution would you merge if someone worked on it)?

Read more comments on GitHub >

github_iconTop Results From Across the Web

nrwl-nx/community - Gitter
Hello . I am using nrwl/nx monorepo with pnpm. During pnpm install I am getting error EISDIR: illegal operation on a directory, read...
Read more >
Using the Nx Dependency Graph in Custom Scripts | juri.dev
Nx caches the dependency graph from previous operations in the node_modules/.cache/nx/nxdeps.json . Hence, we can directly use that cached ...
Read more >
How can I force nrwl nx to respect tag updates? - Stack Overflow
Nx caches a bunch of information concerning dependencies in generated file: /dist/nxdeps.json. You can simply delete this file to ...
Read more >
Project Configuration - Nx
Projects can be configured in package.json (if you use npm scripts and not Nx ... Because keeping them in sync is error-prone, we...
Read more >
nx cannot read properties of undefined (reading 'endswith')
json that version 3.0.0 should be compatible with angular 13 however the npm publish / ci attempt failed with the following error. can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found