I have a Dockerfile that builds an nx app and then serves it, however that docker container runs in read-only mode and that causes this problem:
EROFS: read-only file system, open '/app/node_modules/.cache/nx/project-graph.json~c3501751'
Error: EROFS: read-only file system, open '/app/node_modules/.cache/nx/project-graph.json~c3501751'
at Object.openSync (node:fs:601:3)
at writeFileSync (node:fs:2249:35)
at writeJsonFile (/app/node_modules/nx/src/utils/fileutils.js:56:28)
at writeCache (/app/node_modules/nx/src/project-graph/nx-deps-cache.js:105:43)
at /app/node_modules/nx/src/project-graph/build-project-graph.js:58:44
at Generator.next (<anonymous>)
at fulfilled (/app/node_modules/tslib/tslib.js:164:62)
I don't have serve listed in my cache operations
"cacheableOperations": ["build", "lint", "test", "e2e"],
so I don't know why it's trying to cache on nx serve
(@nx/next:server)
I tried adding "skipNxCache": true
to the taskRunnerOptions
in nx.json
and also I tried using the --skip-nx-cache
flag in the serve command
and nothing works.
Why is serve using cache? any recommendations on how to disable it?
I'm using nx 16.3.0
This worked for me to disable cache write:
The explanation is, if the Daemon is enabled cache is written even if the nx skip cache flag is set to true. Disabling the Daemon then disabling the cache project graph actually disables the cache. More details here