nx
nx copied to clipboard
ERROR: No cached ProjectGraph is available.
Current Behavior
Random nx
crash in our Github CI during a build
Expected Behavior
nx
can build our projects without failing
Steps to Reproduce
I guess new messages at the end of #10730 are kinda similar. Looks related to the latest release.
Failure Logs
> nx run generic-dynamodb-orm:build
Error reading '/home/ubuntu/actions-runner/_work/monorepo/monorepo/node_modules/.cache/nx/nxdeps.json'. Continue the process without the cache.
Error: ValueExpected in /home/ubuntu/actions-runner/_work/monorepo/monorepo/node_modules/.cache/nx/nxdeps.json at position 0
at parseJson (/home/ubuntu/actions-runner/_work/monorepo/monorepo/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/nx/src/utils/json.js:23:15)
at readJsonFile (/home/ubuntu/actions-runner/_work/monorepo/monorepo/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/nx/src/utils/fileutils.js:23:37)
at readCache (/home/ubuntu/actions-runner/_work/monorepo/monorepo/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/nx/src/project-graph/nx-deps-cache.js:41:49)
at readCachedProjectGraph (/home/ubuntu/actions-runner/_work/monorepo/monorepo/node_modules/.pnpm/[email protected]_@[email protected]/node_modules/nx/src/project-graph/project-graph.js:20:61)
at checkDependencies (/home/ubuntu/actions-runner/_work/monorepo/monorepo/node_modules/.pnpm/@[email protected]_2ufozsgst4bthv2r67rno347d4/node_modules/@nrwl/js/src/utils/check-dependencies.js:7:62)
at tscExecutor_1 (/home/ubuntu/actions-runner/_work/monorepo/monorepo/node_modules/.pnpm/@[email protected]_2ufozsgst4bthv2r67rno347d4/node_modules/@nrwl/js/src/executors/tsc/tsc.impl.js:29:111)
at tscExecutor_1.next (<anonymous>)
at resume (/home/ubuntu/actions-runner/_work/monorepo/monorepo/node_modules/.pnpm/[email protected]/node_modules/tslib/tslib.js:230:48)
at /home/ubuntu/actions-runner/_work/monorepo/monorepo/node_modules/.pnpm/[email protected]/node_modules/tslib/tslib.js:229:[125](https://github.com/hublo/monorepo/runs/7410177714?check_suite_focus=true#step:11:126)
at new Promise (<anonymous>)
> NX [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
Pass --verbose to see the stacktrace.
Environment
❯ pnx report
> NX Report complete - copy this into the issue template
Node : 16.15.1
OS : darwin arm64
pnpm : 7.5.0
nx : 14.4.3
@nrwl/angular : Not Found
@nrwl/cypress : 14.4.3
@nrwl/detox : Not Found
@nrwl/devkit : 14.4.3
@nrwl/eslint-plugin-nx : 14.4.3
@nrwl/express : Not Found
@nrwl/jest : 14.4.3
@nrwl/js : 14.4.3
@nrwl/linter : 14.4.3
@nrwl/nest : 14.4.3
@nrwl/next : 14.4.2
@nrwl/node : 14.4.3
@nrwl/nx-cloud : 14.2.0
@nrwl/nx-plugin : Not Found
@nrwl/react : 14.4.3
@nrwl/react-native : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : 14.4.3
@nrwl/web : 14.4.3
@nrwl/workspace : 14.4.3
typescript : 4.7.4
---------------------------------------
Community plugins:
Can you provide the project.json file for generic-dynamodb-orm
?
@AgentEnder Sure
{
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/publish/dynamodb-orm/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nrwl/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/publish/dynamodb-orm",
"tsConfig": "libs/publish/dynamodb-orm/tsconfig.lib.json",
"packageJson": "libs/publish/dynamodb-orm/package.json",
"main": "libs/publish/dynamodb-orm/src/index.ts",
"assets": ["libs/publish/dynamodb-orm/*.md"]
}
},
"typecheck": {
"executor": "@nrwl/workspace:run-commands",
"outputs": ["dist/out-tsc/libs/publish/dynamodb-orm"],
"options": {
"command": "pnpm tsc -b libs/publish/dynamodb-orm/tsconfig.json"
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/publish/dynamodb-orm/**/*.ts"]
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/libs/publish/dynamodb-orm"],
"options": {
"jestConfig": "libs/publish/dynamodb-orm/jest.config.ts",
"passWithNoTests": true
}
}
},
"tags": []
}
Hi, I added comments on #10730 issue which is still closed and I think shouldn't... As this one is open, I'm posting here. Just to let you know that I updated another project with the latest version of Nx (14.4.3) and I have the exact same problem on GitLab CI. If you could please have a look on this, it would help potentially many users. For these 2 projects, I'm staying on 14.3.6 version until this problem is fixed.
Hi @AgentEnder, I think you have the infos you asked for, could you please give us a feedback ? Thank you
I'm also getting this on 13.10.6
on a simple (stock) @nrwl/node:webpack
build as part of a GitHub action.
I'm using nx-electron
in one of the other projects in the workspace, but this isn't the one being built.
I have put nx dep-graph --file dep-graph.json
as an earlier step as per 8288 which works for the time being.
Hello, Just want to prevent the bot from automatically close this issue...
It looks like @nrwl/js:tsc
is leveraging readCachedProjectGraph
, ideally this shouldn't be causing any issues but it could transition to createProjectGraphAsync
. I'll look into this a bit further at some point this week.
Thanks @AgentEnder for your feedback.
Hi, This problem is critical for me. I can build the project on my macbook, but it fails in GitLab CI. @AgentEnder what can I do to solve this problem ? Is there a param I can add to solve this situation the time you try to solve it ? I have now this error on another projet :
> nx run media-ui:build:production
Error reading '/home/gitlab/ci/builds/Ez_cEkkJ/0/massaud/nx-massaud/node_modules/.cache/nx/nxdeps.json'. Continue the process without the cache.
Error: ValueExpected in /home/gitlab/ci/builds/Ez_cEkkJ/0/massaud/nx-massaud/node_modules/.cache/nx/nxdeps.json at position 0
at parseJson (/home/gitlab/ci/builds/Ez_cEkkJ/0/massaud/nx-massaud/node_modules/nx/src/utils/json.js:23:15)
at readJsonFile (/home/gitlab/ci/builds/Ez_cEkkJ/0/massaud/nx-massaud/node_modules/nx/src/utils/fileutils.js:23:37)
at readCache (/home/gitlab/ci/builds/Ez_cEkkJ/0/massaud/nx-massaud/node_modules/nx/src/project-graph/nx-deps-cache.js:41:49)
at readCachedProjectGraph (/home/gitlab/ci/builds/Ez_cEkkJ/0/massaud/nx-massaud/node_modules/nx/src/project-graph/project-graph.js:20:61)
at /home/gitlab/ci/builds/Ez_cEkkJ/0/massaud/nx-massaud/node_modules/@nrwl/angular/src/executors/package/package.impl.js:41:161
at Generator.next (<anonymous>)
at resume (/home/gitlab/ci/builds/Ez_cEkkJ/0/massaud/nx-massaud/node_modules/tslib/tslib.js:230:48)
at /home/gitlab/ci/builds/Ez_cEkkJ/0/massaud/nx-massaud/node_modules/tslib/tslib.js:229:125
at new Promise (<anonymous>)
at Object.i.<computed> [as next] (/home/gitlab/ci/builds/Ez_cEkkJ/0/massaud/nx-massaud/node_modules/tslib/tslib.js:229:67)
at /home/gitlab/ci/builds/Ez_cEkkJ/0/massaud/nx-massaud/node_modules/nx/src/command-line/run.js:52:35
at Generator.next (<anonymous>)
at /home/gitlab/ci/builds/Ez_cEkkJ/0/massaud/nx-massaud/node_modules/tslib/tslib.js:118:75
at new Promise (<anonymous>)
at Object.__awaiter (/home/gitlab/ci/builds/Ez_cEkkJ/0/massaud/nx-massaud/node_modules/tslib/tslib.js:[114](https://gitlab.icilalune.com/massaud/nx-massaud/-/jobs/43635#L114):16)
at iteratorToProcessStatusCode (/home/gitlab/ci/builds/Ez_cEkkJ/0/massaud/nx-massaud/node_modules/nx/src/command-line/run.js:38:20)
> NX [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
Pass --verbose to see the stacktrace.
I upgrade nx to 14.5.5 version, I still have the problem. My CI is KO, I will have to build and deploy manually my projects.
Same problem with 14.5.6
@AgentEnder, Feel free to ask me for test if needed.
Just updated nx to newest version (14.5.6) with nx migrate and got on CI same problem. This is first time, when CI blow up with this type of error. Any progress here? We want to use Angular 14.1 in application
Here is a raport:
Node : 16.16.0 OS : darwin x64 yarn : 1.22.4
nx : 14.5.6 @nrwl/angular : 14.5.6 @nrwl/cypress : 14.5.6 @nrwl/detox : Not Found @nrwl/devkit : 14.5.6 @nrwl/eslint-plugin-nx : 14.5.6 @nrwl/express : Not Found @nrwl/jest : 14.5.6 @nrwl/js : 14.5.6 @nrwl/linter : 14.5.6 @nrwl/nest : 14.5.6 @nrwl/next : Not Found @nrwl/node : 14.5.6 @nrwl/nx-cloud : 14.4.0 @nrwl/nx-plugin : Not Found @nrwl/react : Not Found @nrwl/react-native : Not Found @nrwl/schematics : Not Found @nrwl/storybook : 14.5.6 @nrwl/web : 14.5.6 @nrwl/workspace : 14.5.6 typescript : 4.7.4
Local workspace plugins:
Community plugins: @ngneat/transloco: 2.20.1 @ngrx/effects: 12.5.1 @ngrx/entity: 12.5.1 @ngrx/store: 12.5.1 @ngrx/store-devtools: 12.5.1 @rx-angular/cdk: 1.0.0-beta.3 @rx-angular/state: 1.6.1 @rx-angular/template: 1.0.0-beta.33 rxjs: 6.6.7 @storybook/angular: 6.5.10 @testing-library/angular: 11.0.4
I'm dealing with it since one month, I hope it will be fixed soon.
I'm seeing this issue too in a GitLab pipeline. The frustrating thing is that with NX_CACHE_PROJECT_GRAPH=false
, I get this error. With NX_CACHE_PROJECT_GRAPH=true
, I get a different error saying:
Error reading '/builds/node_modules/.cache/nx/nxdeps.json'. Continue the process without the cache.
Any chances to resolve this issue? We have the same problem
Same here, CI and local instances crash with the error message
Error reading '
npx nx report
> NX Report complete - copy this into the issue template
Node : 14.19.3
OS : linux x64
npm : 6.14.17
nx : 14.5.4
@nrwl/angular : 14.5.4
@nrwl/cypress : 14.5.4
@nrwl/detox : Not Found
@nrwl/devkit : 14.5.4
@nrwl/eslint-plugin-nx : 14.5.4
@nrwl/express : Not Found
@nrwl/jest : 14.5.4
@nrwl/js : 14.5.4
@nrwl/linter : 14.5.4
@nrwl/nest : 14.5.4
@nrwl/next : Not Found
@nrwl/node : 14.5.4
@nrwl/nx-cloud : Not Found
@nrwl/nx-plugin : Not Found
@nrwl/react : Not Found
@nrwl/react-native : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : 14.5.4
@nrwl/web : 14.5.4
@nrwl/workspace : 14.5.4
typescript : 4.7.4
---------------------------------------
Community plugins:
@ngrx/component-store: 14.0.2
@ngrx/effects: 14.0.2
@ngrx/entity: 14.0.2
@ngrx/router-store: 14.0.2
@ngrx/store: 14.0.2
@ngrx/schematics: 14.0.2
@ngrx/store-devtools: 14.0.2
@vsavkin @AgentEnder Hi! I just updated the application to the newest version of nx (14.5.8) and yes you fixed the problem above. But I found the new one. After a first cold build, everything is okay. When I try to rebuild without any changes, I'm getting this error:
ENOENT: no such file or directory, unlink '/Users/illia.mishkin/ppm/ui/node_modules/.cache/nx/latestOutputsHashes/dist-libs-ngplant-core.hash'
When I try to rebuild a third time, the build successfully ends from the cache. For 5 builds, I'm getting 2-3 errors like before.
It looks like a new error. Am I need to create a new ticket?
@B1Z1 I don't think 14.5.8 contains the fix... also in my case the error reading nxdeps.json
seems intermittent
@vsavkin @AgentEnder fix doesn't work. Just after yarn nx clear-cache I started building application and got this:
Could not find 'nx' module in this workspace. 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 at readCachedProjectGraph (/Users/illia.mishkin/ppm/ui/node_modules/nx/src/project-graph/project-graph.js:29:15)
So I think we need to reopen this ticket
Hi all, The problem seems to be fixed for me. One of my projects having the problem has been successfully built 3 times on GitLab CI. Before the nx migrate to 14.5.8, it failed, always. As I see other people still have problems, I'll keep in touch on this issue.
is there a release to test?
@vsavkin @AgentEnder fix doesn't work. Just after yarn nx clear-cache I started building application and got this:
Could not find 'nx' module in this workspace. 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 callingawait 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 at readCachedProjectGraph (/Users/illia.mishkin/ppm/ui/node_modules/nx/src/project-graph/project-graph.js:29:15)
Same error here https://github.com/khalilou88/jnxplus/pull/86
@khalilou88 you should remove the NX_CACHE_PROJECT_GRAPH env variable, its not needed here and is causing the issue.
@AgentEnder thanks for taking the time to look at my Branch. Actually I don't use NX_CACHE_PROJECT_GRAPH in the main branch. I tried this option (NX_CACHE_PROJECT_GRAPH) to fix a e2e test that work fine in local but not in GitHub action.
@AgentEnder on our CI while Jest Tests run, we got this error. I think we cannot close this ticket because sometimes it shows up. Do you need more information from me? We are struggling with it for several months
Here's an error
`Error reading '/home/ubuntu/workspace/PPM/REVIEW/FRONTEND_TESTS/ui/node_modules/.cache/nx/nxdeps.json'. Continue the process without the cache.
[2022-09-02T13:34:53.235Z] Error: UnexpectedEndOfString in /home/ubuntu/workspace/PPM/REVIEW/FRONTEND_TESTS/ui/node_modules/.cache/nx/nxdeps.json at position 4939768
[2022-09-02T13:34:53.235Z] at parseJson (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/src/utils/json.js:23:15)
[2022-09-02T13:34:53.235Z] at readJsonFile (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/src/utils/fileutils.js:23:37)
[2022-09-02T13:34:53.235Z] at readCache (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/src/project-graph/nx-deps-cache.js:41:49)
[2022-09-02T13:34:53.235Z] at readCachedProjectGraph (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/src/project-graph/project-graph.js:20:61)
[2022-09-02T13:34:53.235Z] at run (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/src/command-line/run.js:168:69)
[2022-09-02T13:34:53.235Z] at requireCli (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/bin/run-executor.js:20:23)
[2022-09-02T13:34:53.235Z] at Object.
[2022-09-02T13:34:53.235Z] at Module._compile (node:internal/modules/cjs/loader:1105:14)
[2022-09-02T13:34:53.235Z] at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
[2022-09-02T13:34:53.235Z] at Module.load (node:internal/modules/cjs/loader:981:32)
[2022-09-02T13:34:53.235Z] Could not find 'nx' module in this workspace. Error: [readCachedProjectGraph] ERROR: No cached ProjectGraph is available.
[2022-09-02T13:34:53.235Z]
[2022-09-02T13:34:53.235Z] If you are leveraging `readCachedProjectGraph()` directly then you will need to refactor your usage to first ensure that
[2022-09-02T13:34:53.235Z] the ProjectGraph is created by calling `await createProjectGraphAsync()` somewhere before attempting to read the data.
[2022-09-02T13:34:53.235Z]
[2022-09-02T13:34:53.235Z] If you encounter this error as part of running standard `nx` commands then please open an issue on https://github.com/nrwl/nx
[2022-09-02T13:34:53.235Z] at readCachedProjectGraph (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/src/project-graph/project-graph.js:29:15)
[2022-09-02T13:34:53.235Z] at run (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/src/command-line/run.js:168:69)
[2022-09-02T13:34:53.235Z] at requireCli (/home/ubuntu/jenkins-slave/caches/frontend/node_modules/nx/bin/run-executor.js:20:23)
[2022-09-02T13:34:53.235Z] at Object.
[2022-09-02T13:34:53.235Z] at Module._compile (node:internal/modules/cjs/loader:1105:14)
[2022-09-02T13:34:53.235Z] at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
[2022-09-02T13:34:53.235Z] at Module.load (node:internal/modules/cjs/loader:981:32)
[2022-09-02T13:34:53.235Z] at Function.Module._load (node:internal/modules/cjs/loader:822:12)
[2022-09-02T13:34:53.235Z] at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
[2022-09-02T13:34:53.235Z] at node:internal/main/run_main_module:17:47`
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.