Skip to content

nx run-many fails with ERROR: No cached ProjectGraph is available. #32686

@just-be-weird

Description

@just-be-weird

Current Behavior

I'm facing a very annoying error in our project. I tried to replicate in a small POC and was able to reproduce it. The POC app is an express app with prisma client. Whenever I make any changes in the files the serve command fails and I've to run nx reset and then again run nx run many command to get around this. As our main project is quite huge it has become a big problem.

Expected Behavior

When we make any changes in the files it should run without any errors.

GitHub Repo

https://github.com/just-be-weird/emarket

Steps to Reproduce

  1. Clone the repo
  2. Install the dependencies
  3. Comment out the routes code in services/auth/src/routes/auth.router.ts
import { Router } from 'express';

// import {
//   forgotPassword,
//   verifyUserForgotPassword,
// } from '../controller/forgot-password.controller';
// import { loginUserController } from '../controller/login-user.controller';
// import { resetPassword } from '../controller/reset-password.controller';
// import { userRegistrationController } from '../controller/user-registration.controller';
// import { verifyUserController } from '../controller/verify-user.controller';

const router: Router = Router();

// router.post('/login', loginUserController);
// router.post('/register-user', userRegistrationController);
// router.post('/verify-user', verifyUserController);
// router.post('/forgot-password-user', forgotPassword);
// router.post('/reset-password-user', resetPassword);
// router.post('/verify-forgot-password-user', verifyUserForgotPassword);

export default router;
  1. run pnpm dlx prisma generate and pn dlx prisma db push
  2. run pnpm dev
  3. Now make any changes in let say services/auth/src/main.ts And check the logs of @emarket/auth serve command

Nx Report

NX   Report complete - copy this into the issue template

Node           : 24.7.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 10.15.1

nx (global)        : 21.5.1
nx                 : 21.5.1
@nx/js             : 21.5.1
@nx/jest           : 21.5.1
@nx/eslint         : 21.5.1
@nx/workspace      : 21.5.1
@nx/esbuild        : 21.5.1
@nx/eslint-plugin  : 21.5.1
@nx/express        : 21.5.1
@nx/nest           : 21.5.1
@nx/node           : 21.5.1
@nx/web            : 21.5.1
@nx/webpack        : 21.5.1
@nx/docker         : 21.5.1
typescript         : 5.9.2
---------------------------------------
Registered Plugins:
@nx/js/typescript
@nx/webpack/plugin
@nx/eslint/plugin
@nx/jest/plugin
@nx/docker
---------------------------------------
Cache Usage: 19.87 MB / 46.04 GB

Failure Logs

> nx run @emarket/auth:build

> webpack-cli build --node-env=production

[webpack-cli] Failed to load '/Users/abhishek/Sandbox/learning-poc/services/auth/webpack.config.js' config
[webpack-cli] 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/abhishek/Sandbox/learning-poc/node_modules/.pnpm/nx@21.5.1_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.17__@swc+types@0.1_d7d7785233030ac79f0f77eb63d4afc8/node_modules/nx/src/project-graph/project-graph.js:44:15)
    at normalizeOptions (/Users/abhishek/Sandbox/learning-poc/node_modules/.pnpm/@nx+webpack@21.5.1_@babel+traverse@7.28.4_@swc-node+register@1.9.2_@swc+core@1.5.29_@sw_6c55cc512a055d9298c7ddd4ffb29b3a/node_modules/@nx/webpack/src/plugins/nx-webpack-plugin/lib/normalize-options.js:14:62)
    at new NxAppWebpackPlugin (/Users/abhishek/Sandbox/learning-poc/node_modules/.pnpm/@nx+webpack@21.5.1_@babel+traverse@7.28.4_@swc-node+register@1.9.2_@swc+core@1.5.29_@sw_6c55cc512a055d9298c7ddd4ffb29b3a/node_modules/@nx/webpack/src/plugins/nx-webpack-plugin/nx-app-webpack-plugin.js:22:69)
    at Object.<anonymous> (/Users/abhishek/Sandbox/learning-poc/services/auth/webpack.config.js:12:5)
    at Module._compile (node:internal/modules/cjs/loader:1738:14)
    at Object..js (node:internal/modules/cjs/loader:1871:10)
    at Module.load (node:internal/modules/cjs/loader:1470:32)
    at Module._load (node:internal/modules/cjs/loader:1290:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:238:24)


> nx run @emarket/api-gateway:serve:development

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/abhishek/Sandbox/learning-poc/node_modules/.pnpm/nx@21.5.1_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.17__@swc+types@0.1_d7d7785233030ac79f0f77eb63d4afc8/node_modules/nx/src/project-graph/project-graph.js:44:15)
    at run (/Users/abhishek/Sandbox/learning-poc/node_modules/.pnpm/nx@21.5.1_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.17__@swc+types@0.1_d7d7785233030ac79f0f77eb63d4afc8/node_modules/nx/src/command-line/run/run.js:173:69)
    at process.<anonymous> (/Users/abhishek/Sandbox/learning-poc/node_modules/.pnpm/nx@21.5.1_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.17__@swc+types@0.1_d7d7785233030ac79f0f77eb63d4afc8/node_modules/nx/bin/run-executor.js:59:48)
    at process.emit (node:events:508:28)
    at process.emit (/Users/abhishek/Sandbox/learning-poc/node_modules/.pnpm/nx@21.5.1_@swc-node+register@1.9.2_@swc+core@1.5.29_@swc+helpers@0.5.17__@swc+types@0.1_d7d7785233030ac79f0f77eb63d4afc8/node_modules/nx/src/native/index.js:20:23)
    at emit (node:internal/child_process:949:14)
    at process.processTicksAndRejections (node:internal/process/task_queues:91:21)


   ✔  nx run prisma:build
   ✔  nx run redis:build
   ✔  nx run error-handler:build
   ✔  nx run @emarket/api-gateway:build
   ✖  nx run @emarket/auth:build
   ✖  nx run @emarket/api-gateway:serve:development

—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Cancelled while running target serve for 2 projects and 5 tasks they depend on (1s)

   ✔  4/5 succeeded [4 read from cache]

   ✖  1/5 targets failed, including the following:

      - nx run @emarket/auth:build

   …  2/7 targets had not started.

Package Manager Version

pnpm --version >> 10.15.1

Operating System

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

Additional Information

No response

Metadata

Metadata

Assignees

Labels

priority: highHigh Priority (important issues which affect many people severely)scope: nodeIssues related to Node, Express, NestJS support for Nxtype: bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions