Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failed with Node 21.3.0, Error: readCachedProjectGraph failed #20544

Closed
4 tasks
nodegin opened this issue Dec 2, 2023 · 16 comments
Closed
4 tasks

Build failed with Node 21.3.0, Error: readCachedProjectGraph failed #20544

nodegin opened this issue Dec 2, 2023 · 16 comments
Labels

Comments

@nodegin
Copy link
Contributor

nodegin commented Dec 2, 2023

Current Behavior

I can build my project on my local machine with fresh install,
but when I commit it to my repo and trigger the CI build,
it fails every time with the same error message:
Could not find 'nx' module in this workspace. Error: [readCachedProjectGraph] ERROR: No cached ProjectGraph is available.

Full log:

Dec 2 05:30:43 PM  ==> Checking out commit 3214074ee8b495843bcfac1c9e5e487510b42cd7 in branch fix-ci
Dec 2 05:30:47 PM  ==> Requesting node version >=21.x
Dec 2 05:30:47 PM  (node:36) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
Dec 2 05:30:47 PM  (Use `node --trace-warnings ...` to show where the warning was created)
Dec 2 05:30:47 PM  ==> Using Node version 21.3.0 via /opt/render/project/src/package.json
Dec 2 05:30:47 PM  ==> Docs on specifying a Node version: https://render.com/docs/node-version
Dec 2 05:30:53 PM  ==> Running build command 'npm ci && node render-build.mjs'...
Dec 2 05:30:57 PM  (node:63) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
Dec 2 05:30:57 PM  (Use `node --trace-warnings ...` to show where the warning was created)
Dec 2 05:32:08 PM  
Dec 2 05:32:08 PM  added 2368 packages, and audited 2369 packages in 1m
Dec 2 05:32:08 PM  
Dec 2 05:32:08 PM  350 packages are looking for funding
Dec 2 05:32:08 PM    run `npm fund` for details
Dec 2 05:32:08 PM  
Dec 2 05:32:08 PM  11 moderate severity vulnerabilities
Dec 2 05:32:08 PM  
Dec 2 05:32:08 PM  To address all issues (including breaking changes), run:
Dec 2 05:32:08 PM    npm audit fix --force
Dec 2 05:32:08 PM  
Dec 2 05:32:08 PM  Run `npm audit` for details.
Dec 2 05:32:09 PM  
Dec 2 05:32:09 PM   >  NX   Resetting the Nx workspace cache and stopping the Nx Daemon.
Dec 2 05:32:09 PM  
Dec 2 05:32:09 PM     This might take a few minutes.
Dec 2 05:32:09 PM  
Dec 2 05:32:09 PM  
Dec 2 05:32:09 PM   >  NX   Daemon Server - Stopped
Dec 2 05:32:09 PM  
Dec 2 05:32:09 PM  
Dec 2 05:32:09 PM   >  NX   Successfully reset the Nx workspace.
Dec 2 05:32:09 PM  
Dec 2 05:32:12 PM  
Dec 2 05:32:12 PM   >  NX   Report complete - copy this into the issue template
Dec 2 05:32:12 PM  
Dec 2 05:32:12 PM     Node   : 21.3.0
Dec 2 05:32:12 PM     OS     : linux-x64
Dec 2 05:32:12 PM     npm    : 10.2.4
Dec 2 05:32:12 PM  
Dec 2 05:32:12 PM     nx                 : 17.1.3
Dec 2 05:32:12 PM     @nx/js             : 17.1.3
Dec 2 05:32:12 PM     @nx/linter         : 17.1.3
Dec 2 05:32:12 PM     @nx/eslint         : 17.1.3
Dec 2 05:32:12 PM     @nx/workspace      : 17.1.3
Dec 2 05:32:12 PM     @nx/cypress        : 17.1.3
Dec 2 05:32:12 PM     @nx/devkit         : 17.1.3
Dec 2 05:32:12 PM     @nx/eslint-plugin  : 17.1.3
Dec 2 05:32:12 PM     @nx/react          : 17.1.3
Dec 2 05:32:12 PM     @nx/storybook      : 17.1.3
Dec 2 05:32:12 PM     @nrwl/tao          : 17.1.3
Dec 2 05:32:12 PM     @nx/vite           : 17.1.3
Dec 2 05:32:12 PM     @nx/web            : 17.1.3
Dec 2 05:32:12 PM     typescript         : 4.9.5
Dec 2 05:32:12 PM  
Dec 2 05:32:14 PM  [NX CLOUD] Verifying current cloud bundle
Dec 2 05:32:14 PM  (node:595) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
Dec 2 05:32:14 PM  (Use `node --trace-warnings ...` to show where the warning was created)
Dec 2 05:32:14 PM  [NX CLOUD] Currently installed bundle is invalid, downloading version 2312.01.6  from  https://cloud.nx.app/nx-cloud/static/client-bundle
Dec 2 05:32:15 PM  [NX CLOUD] Done:  /opt/render/project/src/.nx/cache/cloud/2312.01.6
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM   >  NX   Running target build for project web and 1 task it depends on:
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM  [Nx Cloud] Did not identify a VCS platform.
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM   >  NX   RunStart
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM  {
Dec 2 05:32:15 PM    "meta": {},
Dec 2 05:32:15 PM    "branch": null,
Dec 2 05:32:15 PM    "runGroup": "3214074ee8b495843bcfac1c9e5e487510b42cd7",
Dec 2 05:32:15 PM    "ciExecutionId": null,
Dec 2 05:32:15 PM    "ciExecutionEnv": "",
Dec 2 05:32:15 PM    "hashes": [
Dec 2 05:32:15 PM      "13318270150725750156",
Dec 2 05:32:15 PM      "16697682022918137113"
Dec 2 05:32:15 PM    ],
Dec 2 05:32:15 PM    "machineInfo": {
Dec 2 05:32:15 PM      "machineId": "ubRguwX2ERTAK3dlextrOA==",
Dec 2 05:32:15 PM      "platform": "linux",
Dec 2 05:32:15 PM      "version": "#16~22.04.1-Ubuntu SMP Sun Nov  5 20:08:16 UTC 2023",
Dec 2 05:32:15 PM      "cpuCores": 16
Dec 2 05:32:15 PM    },
Dec 2 05:32:15 PM    "vcsContext": null
Dec 2 05:32:15 PM  }
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM   >  NX   Nx Cloud: Cache miss 16697682022918137113.
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM  > nx run shared-ui:build:production
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM  Could not find 'nx' module in this workspace. Error: [readCachedProjectGraph] ERROR: No cached ProjectGraph is available.
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM  If you are leveraging \`readCachedProjectGraph()\` directly then you will need to refactor your usage to first ensure that
Dec 2 05:32:15 PM  the ProjectGraph is created by calling \`await createProjectGraphAsync()\` somewhere before attempting to read the data.
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM  If you encounter this error as part of running standard \`nx\` commands then please open an issue on https://github.com/nrwl/nx
Dec 2 05:32:15 PM      at readCachedProjectGraph (/opt/render/project/src/node_modules/nx/src/project-graph/project-graph.js:30:15)
Dec 2 05:32:15 PM      at run (/opt/render/project/src/node_modules/nx/src/command-line/run/run.js:151:69)
Dec 2 05:32:15 PM      at process.<anonymous> (/opt/render/project/src/node_modules/nx/bin/run-executor.js:59:48)
Dec 2 05:32:15 PM      at process.emit (node:events:519:28)
Dec 2 05:32:15 PM      at emit (node:internal/child_process:951:14)
Dec 2 05:32:15 PM      at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM   >  NX   Running target build for project web and 1 task it depends on failed
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM     Failed tasks:
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM     - shared-ui:build:production
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM     Hint: run the command with --verbose for more details.
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM   >  NX   Nx Cloud Problems
Dec 2 05:32:15 PM  
Dec 2 05:32:15 PM     - Error when connecting to Nx Cloud. Code: 401. Error: This workspace is more than a week old and is unclaimed. Workspaces must be claimed within 7 days of creation. Claim your workspace at https://cloud.nx.app/orgs/workspace-setup?accessToken=
Dec 2 05:32:15 PM  
Dec 2 05:32:17 PM  [NX CLOUD] Verifying current cloud bundle
Dec 2 05:32:17 PM  [NX CLOUD] A local bundle currently exists:  {
Dec 2 05:32:17 PM    version: '2312.01.6',
Dec 2 05:32:17 PM    fullPath: '/opt/render/project/src/.nx/cache/cloud/2312.01.6'
Dec 2 05:32:17 PM  }
Dec 2 05:32:17 PM  [NX CLOUD] Last verification was within the past 30 minutes, will not verify this time
Dec 2 05:32:17 PM  [NX CLOUD] Done:  /opt/render/project/src/.nx/cache/cloud/2312.01.6
Dec 2 05:32:17 PM  [Nx Cloud] Did not identify a VCS platform.
Dec 2 05:32:17 PM  
Dec 2 05:32:17 PM   >  NX   RunStart
Dec 2 05:32:17 PM  
Dec 2 05:32:17 PM  
Dec 2 05:32:17 PM  {
Dec 2 05:32:17 PM    "meta": {},
Dec 2 05:32:17 PM    "branch": null,
Dec 2 05:32:17 PM    "runGroup": "3214074ee8b495843bcfac1c9e5e487510b42cd7",
Dec 2 05:32:17 PM    "ciExecutionId": null,
Dec 2 05:32:17 PM    "ciExecutionEnv": "",
Dec 2 05:32:17 PM    "hashes": [
Dec 2 05:32:17 PM      "5935880398960322236"
Dec 2 05:32:17 PM    ],
Dec 2 05:32:17 PM    "machineInfo": {
Dec 2 05:32:17 PM      "machineId": "ubRguwX2ERTAK3dlextrOA==",
Dec 2 05:32:17 PM      "platform": "linux",
Dec 2 05:32:17 PM      "version": "#16~22.04.1-Ubuntu SMP Sun Nov  5 20:08:16 UTC 2023",
Dec 2 05:32:17 PM      "cpuCores": 16
Dec 2 05:32:17 PM    },
Dec 2 05:32:17 PM    "vcsContext": null
Dec 2 05:32:17 PM  }
Dec 2 05:32:17 PM  
Dec 2 05:32:17 PM  (node:667) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
Dec 2 05:32:17 PM  (Use `node --trace-warnings ...` to show where the warning was created)
Dec 2 05:32:17 PM  
Dec 2 05:32:17 PM   >  NX   Nx Cloud: Cache miss 5935880398960322236.
Dec 2 05:32:17 PM  
Dec 2 05:32:17 PM  
Dec 2 05:32:17 PM  > nx run api:build:production
Dec 2 05:32:17 PM  
Dec 2 05:32:18 PM  Could not find 'nx' module in this workspace. Error: [readCachedProjectGraph] ERROR: No cached ProjectGraph is available.
Dec 2 05:32:18 PM  
Dec 2 05:32:18 PM  If you are leveraging \`readCachedProjectGraph()\` directly then you will need to refactor your usage to first ensure that
Dec 2 05:32:18 PM  the ProjectGraph is created by calling \`await createProjectGraphAsync()\` somewhere before attempting to read the data.
Dec 2 05:32:18 PM  
Dec 2 05:32:18 PM  If you encounter this error as part of running standard \`nx\` commands then please open an issue on https://github.com/nrwl/nx
Dec 2 05:32:18 PM      at readCachedProjectGraph (/opt/render/project/src/node_modules/nx/src/project-graph/project-graph.js:30:15)
Dec 2 05:32:18 PM      at run (/opt/render/project/src/node_modules/nx/src/command-line/run/run.js:151:69)
Dec 2 05:32:18 PM      at process.<anonymous> (/opt/render/project/src/node_modules/nx/bin/run-executor.js:59:48)
Dec 2 05:32:18 PM      at process.emit (node:events:519:28)
Dec 2 05:32:18 PM      at emit (node:internal/child_process:951:14)
Dec 2 05:32:18 PM      at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
Dec 2 05:32:18 PM  
Dec 2 05:32:18 PM  
Dec 2 05:32:18 PM  
Dec 2 05:32:18 PM   >  NX   Running target build for project api failed
Dec 2 05:32:18 PM  
Dec 2 05:32:18 PM     Failed tasks:
Dec 2 05:32:18 PM  
Dec 2 05:32:18 PM     - api:build:production
Dec 2 05:32:18 PM  
Dec 2 05:32:18 PM     Hint: run the command with --verbose for more details.
Dec 2 05:32:18 PM  
Dec 2 05:32:18 PM  
Dec 2 05:32:18 PM   >  NX   Nx Cloud Problems
Dec 2 05:32:18 PM  
Dec 2 05:32:18 PM     - Error when connecting to Nx Cloud. Code: 401. Error: This workspace is more than a week old and is unclaimed. Workspaces must be claimed within 7 days of creation. Claim your workspace at https://cloud.nx.app/orgs/workspace-setup?accessToken=
Dec 2 05:32:18 PM  
Dec 2 05:32:18 PM  ==> Uploading build...
Dec 2 05:32:39 PM  ==> Build uploaded in 11s
Dec 2 05:32:39 PM  ==> Build successful 🎉
Dec 2 05:32:41 PM  ==> Deploying...
Dec 2 05:33:17 PM  ==> Requesting node version >=21.x
Dec 2 05:33:17 PM  (node:41) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
Dec 2 05:33:17 PM  (Use `node --trace-warnings ...` to show where the warning was created)
Dec 2 05:33:18 PM  ==> Using Node version 21.3.0 via /opt/render/project/src/package.json
Dec 2 05:33:18 PM  ==> Docs on specifying a Node version: https://render.com/docs/node-version
Dec 2 05:33:18 PM  ==> Running 'node dist/apps/api/main.js'
Dec 2 05:33:18 PM  node:internal/modules/cjs/loader:1147
Dec 2 05:33:18 PM    throw err;
Dec 2 05:33:18 PM    ^
Dec 2 05:33:18 PM  
Dec 2 05:33:18 PM  Error: Cannot find module '/opt/render/project/src/dist/apps/api/main.js'
Dec 2 05:33:18 PM      at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
Dec 2 05:33:18 PM      at Module._load (node:internal/modules/cjs/loader:985:27)
Dec 2 05:33:18 PM      at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
Dec 2 05:33:18 PM      at node:internal/main/run_main_module:28:49 {
Dec 2 05:33:18 PM    code: 'MODULE_NOT_FOUND',
Dec 2 05:33:18 PM    requireStack: []
Dec 2 05:33:18 PM  }
Dec 2 05:33:18 PM  
Dec 2 05:33:18 PM  Node.js v21.3.0
Dec 2 05:33:22 PM  ==> Requesting node version >=21.x
Dec 2 05:33:22 PM  ==> Using Node version 21.3.0 via /opt/render/project/src/package.json
Dec 2 05:33:22 PM  ==> Docs on specifying a Node version: https://render.com/docs/node-version
Dec 2 05:33:22 PM  ==> Running 'node dist/apps/api/main.js'
Dec 2 05:33:23 PM  node:internal/modules/cjs/loader:1147
Dec 2 05:33:23 PM    throw err;
Dec 2 05:33:23 PM    ^
Dec 2 05:33:23 PM  
Dec 2 05:33:23 PM  Error: Cannot find module '/opt/render/project/src/dist/apps/api/main.js'
Dec 2 05:33:23 PM      at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
Dec 2 05:33:23 PM      at Module._load (node:internal/modules/cjs/loader:985:27)
Dec 2 05:33:23 PM      at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
Dec 2 05:33:23 PM      at node:internal/main/run_main_module:28:49 {
Dec 2 05:33:23 PM    code: 'MODULE_NOT_FOUND',
Dec 2 05:33:23 PM    requireStack: []
Dec 2 05:33:23 PM  }
Dec 2 05:33:23 PM  
Dec 2 05:33:23 PM  Node.js v21.3.0

Expected Behavior

It should build the project successfully

GitHub Repo

No response

Steps to Reproduce

  1. Prepare the build script:
// build.mjs
import { spawn } from 'child_process';

function run(cmd) {
  return new Promise((resolve) => {
    const proc = spawn('sh', ['-c', cmd]);

    proc.stdout.on('data', (data) => {
      process.stdout.write(data);
    });

    proc.stderr.on('data', (data) => {
      process.stderr.write(data);
    });

    proc.on('exit', (code) => {
      resolve(code);
    });
  });
}

(async () => {
  await run('rm -rf .nx');
  await run('npx nx reset');
  await run('nx report');
  await run('npx nx build web --verbose');
})();
  1. npm ci && node build.mjs

Nx Report

Dec 2 05:32:12 PM     Node   : 21.3.0
Dec 2 05:32:12 PM     OS     : linux-x64
Dec 2 05:32:12 PM     npm    : 10.2.4
Dec 2 05:32:12 PM  
Dec 2 05:32:12 PM     nx                 : 17.1.3
Dec 2 05:32:12 PM     @nx/js             : 17.1.3
Dec 2 05:32:12 PM     @nx/linter         : 17.1.3
Dec 2 05:32:12 PM     @nx/eslint         : 17.1.3
Dec 2 05:32:12 PM     @nx/workspace      : 17.1.3
Dec 2 05:32:12 PM     @nx/cypress        : 17.1.3
Dec 2 05:32:12 PM     @nx/devkit         : 17.1.3
Dec 2 05:32:12 PM     @nx/eslint-plugin  : 17.1.3
Dec 2 05:32:12 PM     @nx/react          : 17.1.3
Dec 2 05:32:12 PM     @nx/storybook      : 17.1.3
Dec 2 05:32:12 PM     @nrwl/tao          : 17.1.3
Dec 2 05:32:12 PM     @nx/vite           : 17.1.3
Dec 2 05:32:12 PM     @nx/web            : 17.1.3
Dec 2 05:32:12 PM     typescript         : 4.9.5

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@nodegin
Copy link
Contributor Author

nodegin commented Dec 2, 2023

I already tried to run npx nx reset
but seem project-graph.json is not created at all.

@nodegin
Copy link
Contributor Author

nodegin commented Dec 2, 2023

I can run npx nx graph --file=/tmp/graph.json in local but fails in CI too:

Local result:

 >  NX   JSON output contains deprecated fields:

   - affectedProjects
   - criticalPath

   These fields will be removed in Nx 18. If you need to see which projects were affected, use `nx show projects --affected`.


 >  NX   JSON output created in /tmp

   /tmp/graph.json

CI:

Dec 2 06:59:02 PM  Graph dependencies within workspace
Dec 2 06:59:02 PM  
Dec 2 06:59:02 PM  Run command using --base=[SHA1] (affected by the committed, uncommitted and untracked changes):
Dec 2 06:59:02 PM    --base  Base of the current branch (usually main)  [string]
Dec 2 06:59:02 PM  
Dec 2 06:59:02 PM  or using --base=[SHA1] --head=[SHA2] (affected by the committed changes):
Dec 2 06:59:02 PM    --base  Base of the current branch (usually main)  [string]
Dec 2 06:59:02 PM    --head  Latest commit of the current branch (usually HEAD)  [string]
Dec 2 06:59:02 PM  
Dec 2 06:59:02 PM  or using:
Dec 2 06:59:02 PM    --files        Change the way Nx is calculating the affected command by providing directly changed files, list of files delimited by commas or spaces  [string]
Dec 2 06:59:02 PM    --uncommitted  Uncommitted changes  [boolean]
Dec 2 06:59:02 PM    --untracked    Untracked changes  [boolean]
Dec 2 06:59:02 PM  
Dec 2 06:59:02 PM  Options:
Dec 2 06:59:02 PM    --help           Show help  [boolean]
Dec 2 06:59:02 PM    --version        Show version number  [boolean]
Dec 2 06:59:02 PM    --file           Output file (e.g. --file=output.json or --file=dep-graph.html)  [string]
Dec 2 06:59:02 PM    --view           Choose whether to view the projects or task graph  [string] [choices: "projects", "tasks"] [default: "projects"]
Dec 2 06:59:02 PM    --targets        The target to show tasks for in the task graph  [string]
Dec 2 06:59:02 PM    --focus          Use to show the project graph for a particular project and every node that is either an ancestor or a descendant.  [string]
Dec 2 06:59:02 PM    --exclude        Exclude certain projects from being processed  [string]
Dec 2 06:59:02 PM    --groupByFolder  Group projects by folder in the project graph  [boolean]
Dec 2 06:59:02 PM    --host           Bind the project graph server to a specific ip address.  [string]
Dec 2 06:59:02 PM    --port           Bind the project graph server to a specific port.  [number]
Dec 2 06:59:02 PM    --watch          Watch for changes to project graph and update in-browser  [boolean] [default: false]
Dec 2 06:59:02 PM    --open           Open the project graph in the browser.  [boolean] [default: true]
Dec 2 06:59:02 PM    --affected       Highlight affected projects  [boolean]
Dec 2 06:59:02 PM  
Dec 2 06:59:02 PM  Find more information and examples at https://nx.dev/nx/dep-graph
Dec 2 06:59:02 PM  
Dec 2 06:59:02 PM  Error: ENOENT: no such file or directory, open '/tmp/graphl.json'
Dec 2 06:59:02 PM      at writeFileSync (node:fs:2352:20)
Dec 2 06:59:02 PM      at writeJsonFile (/opt/render/project/src/node_modules/nx/src/utils/fileutils.js:55:28)
Dec 2 06:59:02 PM      at Object.generateGraph (/opt/render/project/src/node_modules/nx/src/command-line/graph/graph.js:219:43)
Dec 2 06:59:02 PM      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Dec 2 06:59:02 PM      at async Object.handler (/opt/render/project/src/node_modules/nx/src/command-line/graph/command-object.js:20:30) {
Dec 2 06:59:02 PM    errno: -2,
Dec 2 06:59:02 PM    code: 'ENOENT',
Dec 2 06:59:02 PM    syscall: 'open',
Dec 2 06:59:02 PM    path: '/tmp/graphl.json'
Dec 2 06:59:02 PM  }

@benjiminio
Copy link

benjiminio commented Dec 2, 2023

I have the same issue, also hosted on Render. With my last commit ~12 hours ago everything worked as expected.

nx reset didn't help

CI:

Dec 2 10:48:11 AM  #18 [builder 11/11] RUN npm run build:projectx-worker     && npm prune --production
Dec 2 10:48:12 AM  #18 1.314
Dec 2 10:48:12 AM  #18 1.314 > projectx-mono@1.0.0 build:projectx-worker
Dec 2 10:48:12 AM  #18 1.314 > nx build --project=projectx-worker
Dec 2 10:48:12 AM  #18 1.314
Dec 2 10:48:14 AM  #18 3.394
Dec 2 10:48:14 AM  #18 3.394 > nx run projectx-worker:build:production
Dec 2 10:48:14 AM  #18 3.394
Dec 2 10:48:15 AM  #18 3.691 Could not find 'nx' module in this workspace. Error: [readCachedProjectGraph] ERROR: No cached ProjectGraph is available.
Dec 2 10:48:15 AM  #18 3.691
Dec 2 10:48:15 AM  #18 3.691 If you are leveraging \`readCachedProjectGraph()\` directly then you will need to refactor your usage to first ensure that
Dec 2 10:48:15 AM  #18 3.691 the ProjectGraph is created by calling \`await createProjectGraphAsync()\` somewhere before attempting to read the data.
Dec 2 10:48:15 AM  #18 3.691
Dec 2 10:48:15 AM  #18 3.691 If you encounter this error as part of running standard \`nx\` commands then please open an issue on https://github.com/nrwl/nx
Dec 2 10:48:15 AM  #18 3.691     at readCachedProjectGraph (/app/node_modules/nx/src/project-graph/project-graph.js:29:15)
Dec 2 10:48:15 AM  #18 3.691     at run (/app/node_modules/nx/src/command-line/run/run.js:151:69)
Dec 2 10:48:15 AM  #18 3.691     at process.<anonymous> (/app/node_modules/nx/bin/run-executor.js:59:48)
Dec 2 10:48:15 AM  #18 3.691     at process.emit (node:events:519:28)
Dec 2 10:48:15 AM  #18 3.691     at emit (node:internal/child_process:951:14)
Dec 2 10:48:15 AM  #18 3.691     at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
Dec 2 10:48:15 AM  #18 3.716
Dec 2 10:48:15 AM  #18 3.717
Dec 2 10:48:15 AM  #18 3.717
Dec 2 10:48:15 AM  #18 3.717  >  NX   Running target build for project projectx-worker failed

@nodegin
Copy link
Contributor Author

nodegin commented Dec 2, 2023

@benjiminio I noticed on Render CI environment,
the group permission is become s found under ls command.

Local:

./nx/cache total 5288
drwxr-xr-x@ 14 user  staff   448B 12  2 19:14 .
drwxr-xr-x@  3 user  staff    96B 12  2 19:14 ..
drwxr-xr-x@  6 user  staff   192B 12  2 19:14 13318270150725750156
-rw-r--r--@  1 user  staff     4B 12  2 19:14 13318270150725750156.commit
drwxr-xr-x@  6 user  staff   192B 12  2 19:14 16697682022918137113
-rw-r--r--@  1 user  staff     4B 12  2 19:14 16697682022918137113.commit
drwxr-xr-x@  4 user  staff   128B 12  2 19:14 cloud
drwxr-xr-x@  4 user  staff   128B 12  2 19:14 d
-rw-r--r--@  1 user  staff    74K 12  2 19:14 file-map.json
-rw-r--r--@  1 user  staff    19B 12  2 19:14 lockfile.hash
-rw-r--r--@  1 user  staff   1.2M 12  2 19:14 parsed-lock-file.json
-rw-r--r--@  1 user  staff   1.3M 12  2 19:14 project-graph.json
-rw-r--r--@  1 user  staff   822B 12  2 19:14 run.json
drwxr-xr-x@  5 user  staff   160B 12  2 19:14 terminalOutputs

CI:

Dec 2 07:29:16 PM   ./nx/cache total 1.3M
Dec 2 07:29:16 PM  drwxr-sr-x 5 render render 4.0K Dec  2 10:29 .
Dec 2 07:29:16 PM  drwxr-sr-x 3 render render 4.0K Dec  2 10:28 ..
Dec 2 07:29:16 PM  drwxr-sr-x 3 render render 4.0K Dec  2 10:28 cloud
Dec 2 07:29:16 PM  drwxr-sr-x 2 render render 4.0K Dec  2 10:29 d
Dec 2 07:29:16 PM  -rw-r--r-- 1 render render   19 Dec  2 10:28 lockfile.hash
Dec 2 07:29:16 PM  -rw-r--r-- 1 render render 1.3M Dec  2 10:28 parsed-lock-file.json
Dec 2 07:29:16 PM  drwxr-sr-x 2 render render 4.0K Dec  2 10:29 terminalOutputs

So maybe this is why NX cannot create the file?
But I don't have a fix yet.

@benjiminio
Copy link

benjiminio commented Dec 2, 2023

Not sure it has something to do with Render. I get the error locally in Docker as well:

 > [builder 11/11] RUN npm run build:projectx-worker     && npm prune --production:
0.481
0.481 > projectx-mono@1.0.0 build:projectx-worker
0.481 > nx build --project=projectx-worker
0.481
0.891 ERROR (1) when writing
0.891 ENOENT: no such file or directory, open '/app/.nx/cache/project-graph.json~434e7c89'
0.891 Error: ENOENT: no such file or directory, open '/app/.nx/cache/project-graph.json~434e7c89'
0.891     at writeFileSync (node:fs:2352:20)
0.891     at writeJsonFile (/app/node_modules/nx/src/utils/fileutils.js:55:28)
0.891     at writeCache (/app/node_modules/nx/src/project-graph/nx-deps-cache.js:104:43)
0.891     at buildProjectGraphUsingProjectFileMap (/app/node_modules/nx/src/project-graph/build-project-graph.js:56:40)
0.891     at async buildProjectGraphWithoutDaemon (/app/node_modules/nx/src/project-graph/project-graph.js:66:13)
0.891     at async createProjectGraphAsync (/app/node_modules/nx/src/project-graph/project-graph.js:113:25)
0.891     at async Object.runOne (/app/node_modules/nx/src/command-line/run/run-one.js:21:26)
0.894 ERROR (2) when writing
0.894 ENOENT: no such file or directory, open '/app/.nx/cache/project-graph.json~d31a9a32'
0.894 Error: ENOENT: no such file or directory, open '/app/.nx/cache/project-graph.json~d31a9a32'
0.894     at writeFileSync (node:fs:2352:20)
0.894     at writeJsonFile (/app/node_modules/nx/src/utils/fileutils.js:55:28)
0.894     at writeCache (/app/node_modules/nx/src/project-graph/nx-deps-cache.js:104:43)
0.894     at buildProjectGraphUsingProjectFileMap (/app/node_modules/nx/src/project-graph/build-project-graph.js:56:40)
0.894     at async buildProjectGraphWithoutDaemon (/app/node_modules/nx/src/project-graph/project-graph.js:66:13)
0.894     at async createProjectGraphAsync (/app/node_modules/nx/src/project-graph/project-graph.js:113:25)
0.894     at async Object.runOne (/app/node_modules/nx/src/command-line/run/run-one.js:21:26)
0.896 ERROR (3) when writing
0.896 ENOENT: no such file or directory, open '/app/.nx/cache/project-graph.json~282a9570'
0.896 Error: ENOENT: no such file or directory, open '/app/.nx/cache/project-graph.json~282a9570'
0.896     at writeFileSync (node:fs:2352:20)
0.896     at writeJsonFile (/app/node_modules/nx/src/utils/fileutils.js:55:28)
0.896     at writeCache (/app/node_modules/nx/src/project-graph/nx-deps-cache.js:104:43)
0.896     at buildProjectGraphUsingProjectFileMap (/app/node_modules/nx/src/project-graph/build-project-graph.js:56:40)
0.896     at async buildProjectGraphWithoutDaemon (/app/node_modules/nx/src/project-graph/project-graph.js:66:13)
0.896     at async createProjectGraphAsync (/app/node_modules/nx/src/project-graph/project-graph.js:113:25)
0.896     at async Object.runOne (/app/node_modules/nx/src/command-line/run/run-one.js:21:26)
0.898 ERROR (4) when writing
0.898 ENOENT: no such file or directory, open '/app/.nx/cache/project-graph.json~4816fd66'
0.898 Error: ENOENT: no such file or directory, open '/app/.nx/cache/project-graph.json~4816fd66'
0.898     at writeFileSync (node:fs:2352:20)
0.898     at writeJsonFile (/app/node_modules/nx/src/utils/fileutils.js:55:28)
0.898     at writeCache (/app/node_modules/nx/src/project-graph/nx-deps-cache.js:104:43)
0.898     at buildProjectGraphUsingProjectFileMap (/app/node_modules/nx/src/project-graph/build-project-graph.js:56:40)
0.898     at async buildProjectGraphWithoutDaemon (/app/node_modules/nx/src/project-graph/project-graph.js:66:13)
0.898     at async createProjectGraphAsync (/app/node_modules/nx/src/project-graph/project-graph.js:113:25)
0.898     at async Object.runOne (/app/node_modules/nx/src/command-line/run/run-one.js:21:26)
0.941
0.941 > nx run projectx-worker:build:production
0.941
0.994 Could not find 'nx' module in this workspace. Error: [readCachedProjectGraph] ERROR: No cached ProjectGraph is available.
0.994
0.994 If you are leveraging \`readCachedProjectGraph()\` directly then you will need to refactor your usage to first ensure that
0.994 the ProjectGraph is created by calling \`await createProjectGraphAsync()\` somewhere before attempting to read the data.
0.994
0.994 If you encounter this error as part of running standard \`nx\` commands then please open an issue on https://github.com/nrwl/nx
0.994     at readCachedProjectGraph (/app/node_modules/nx/src/project-graph/project-graph.js:29:15)
0.994     at run (/app/node_modules/nx/src/command-line/run/run.js:151:69)
0.994     at process.<anonymous> (/app/node_modules/nx/bin/run-executor.js:59:48)
0.994     at process.emit (node:events:519:28)
0.994     at emit (node:internal/child_process:951:14)
0.994     at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
1.000
1.000
1.000
1.000  >  NX   Running target build for project projectx-worker failed

@cskiwi
Copy link

cskiwi commented Dec 2, 2023

I suddenly also have this issue on one of my deloyments (of 3 servies I deploy with nx)

UPDATE: if I put the build on the same version as the local install (CI was building on node 21, and local was 20). then it all works again

@domwebber
Copy link

Same issue here - CI with GitHub Actions, changing node-version in the actions/setup-node step to exactly match my local version stopped the CI runs from failing for me.

Here's the commit that fixed my issues, changing 21.x to 21.1, matching my local install.

image
image

@benjiminio
Copy link

Similar solution in my case: defining the exact node version in the Dockerfile.

ARG NODE_VERSION=18.16.1
FROM node:${NODE_VERSION}-slim as builder

@MooDySmiles
Copy link

I tried with different versions of node, up to 21.2 everything works fine, with 21.3 I get this error on local and on CI 🤷🏼

@nodegin
Copy link
Contributor Author

nodegin commented Dec 4, 2023

So it seem the issue is caused by the Node 21.3.0 release,
by explicitly setting the Node version to 21.2.0 in package.json

  "engines": {
    "node": "21.2.0"
  },

The build is working again in CI

@nodegin nodegin changed the title Build failed on CI only. Could not find 'nx' module in this workspace. Error: [readCachedProjectGraph] ERROR: No cached ProjectGraph is available. Build failed with Node 21.3.0, Error: readCachedProjectGraph failed Dec 4, 2023
@juristr juristr added the scope: core core nx functionality label Dec 4, 2023
@nodegin
Copy link
Contributor Author

nodegin commented Dec 4, 2023

Seem related to this issue;
nodejs/node#50989

@batazor
Copy link
Contributor

batazor commented Dec 6, 2023

Version 21.4 is released, this fixed some of the problems

@joshua-auchincloss
Copy link

pretty sure this is related to #20551 - downgrading to lts/iron or upgrading to 21.4.0 should work

@mklueh
Copy link

mklueh commented Dec 9, 2023

Also had this problem.

Upgrading Node to 21.4.0 has indeed helped and also resolved another issue I had when running nx migrate

$ nx migrate nx@17.2.0 --verbose
Failed to install the latest version of the migration script. Using the current version.
Fetching meta data about packages.
It may take a few minutes.
Fetching nx@17.2.0
Fetching nx@17.2.0

 >  NX   The migrate command failed.


 >  NX   ENOENT: no such file or directory, open 'C:\Users\User\AppData\Local\Temp\tmp-16108-uRlkORG4yBJL\package.json'


Error: ENOENT: no such file or directory, open 'C:\Users\User\AppData\Local\Temp\tmp-16108-uRlkORG4yBJL\package.json'
    at writeFileSync (node:fs:2352:20)
    at writeJsonFile (C:\Users\User\Workspace\my-project\node_modules\nx\src\utils\fileutils.js:55:28)
    at createTempNpmDirectory (C:\Users\User\Workspace\my-project\node_modules\nx\src\utils\package-manager.js:209:35)
    at getPackageMigrationsUsingInstall (C:\Users\User\Workspace\my-project\node_modules\nx\src\command-line\migrate\migrate.js:623:75)
    at C:\Users\User\Workspace\my-project\node_modules\nx\src\command-line\migrate\migrate.js:543:20
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Migrator.populatePackageJsonUpdatesAndGetPackagesToCheck (C:\Users\User\Workspace\my-project\node_modules\nx\src\command-line\migrate\migrate.js:144:31)
    at async Migrator.buildPackageJsonUpdates (C:\Users\User\Workspace\my-project\node_modules\nx\src\command-line\migrate\migrate.js:114:33)
    at async Migrator.migrate (C:\Users\User\Workspace\my-project\node_modules\nx\src\command-line\migrate\migrate.js:80:9)
    at async generateMigrationsJsonAndUpdatePackageJson (C:\Users\User\Workspace\my-project\node_modules\nx\src\command-line\migrate\migrate.js:783:78)
Command failed: yarn nx _migrate nx@17.2.0 --verbose

Now I'm running in this issue #20675

 >  NX   The migrate command failed.


 >  NX   Command failed: yarn add -W @nrwl/workspace@17.2.0

   warning package.json: No license field
   warning No license field
   (node:15916) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
   (Use `node --trace-deprecation ...` to show where the warning was created)
   error https://registry.yarnpkg.com/@nx/workspace/-/workspace-17.2.0.tgz: Extracting tar content of undefined failed, the file appears to be corrupt: "ENOENT: no such file or directory, stat 'C:\\Users\\User\\AppData\\Local\\Yarn\\Cache\\v6\\npm-@nx-workspace-17.2.0-ef1e399614df0d740529a331ebaab01d6694a1a0-integrity\\node_modules\\@nx\\workspace\\src\\generators\\remove\\schema.json'"
   
   Pass --verbose to see the stacktrace.

Command failed: C:\Users\User\AppData\Local\Temp\tmp-15544-KZSPzLqXSPG7\node_modules\.bin\nx _migrate nx@17.2.0


@jaysoo
Copy link
Member

jaysoo commented Dec 12, 2023

The odd Node versions aren't stable and Nx does not guarantee support for them. I would recommend not using any odd versions for production.

@nodegin nodegin closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2023
Copy link

github-actions bot commented Feb 8, 2024

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

10 participants