nx icon indicating copy to clipboard operation
nx copied to clipboard

Nest serve error (22.2.0)

Open PoMaKoM opened this issue 4 days ago • 4 comments

Current Behavior

Comand failed

nx run my-nest-app:serve:development

Expected Behavior

Serve works normally and starts without errors.

GitHub Repo

No response

Steps to Reproduce

  1. Install and initialize nx 22.2.0
  2. nx add @nx/nest
  3. nx g @nx/nest:app apps/my-nest-app
  4. nx serve my-nest-app
  • All packages are 22.2.0

Nx Report

Sorry, no report

Failure Logs

> nx run my-nest-app:serve:development

NX Daemon is not running. Node process will not restart automatically after file changes.
node:internal/modules/cjs/loader:1207
  const err = new Error(message);
              ^

Error: Cannot find module 'nx'
Require stack:
- D:\Projects\Own\short-warden\node_modules\@nx\js\src\executors\node\node.impl.js
- D:\Projects\Own\short-warden\node_modules\nx\src\config\schema-utils.js
- D:\Projects\Own\short-warden\node_modules\nx\src\command-line\run\executor-utils.js
- D:\Projects\Own\short-warden\node_modules\nx\src\project-graph\utils\project-configuration-utils.js
- D:\Projects\Own\short-warden\node_modules\nx\src\utils\package-json.js
- D:\Projects\Own\short-warden\node_modules\nx\src\utils\print-help.js
- D:\Projects\Own\short-warden\node_modules\nx\src\command-line\run\run.js
- D:\Projects\Own\short-warden\node_modules\nx\bin\run-executor.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1207:15)
    at Function.resolve (node:internal/modules/helpers:193:19)
    at D:\Projects\Own\short-warden\node_modules\@nx\js\src\executors\node\node.impl.js:211:70
    at new Promise (<anonymous>)
    at runBuild (D:\Projects\Own\short-warden\node_modules\@nx\js\src\executors\node\node.impl.js:210:35)
    at D:\Projects\Own\short-warden\node_modules\@nx\js\src\executors\node\node.impl.js:252:19
    at [Symbol.asyncIterator] (D:\Projects\Own\short-warden\node_modules\@nx\devkit\src\utils\async-iterable\create-async-iterable.js:12:13)       
    at nodeExecutor (D:\Projects\Own\short-warden\node_modules\@nx\js\src\executors\node\node.impl.js:61:53)
    at nodeExecutor.next (<anonymous>)
    at getLastValueFromAsyncIterableIterator (D:\Projects\Own\short-warden\node_modules\nx\src\utils\async-iterator.js:15:34) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'D:\\Projects\\Own\\short-warden\\node_modules\\@nx\\js\\src\\executors\\node\\node.impl.js',
    'D:\\Projects\\Own\\short-warden\\node_modules\\nx\\src\\config\\schema-utils.js',
    'D:\\Projects\\Own\\short-warden\\node_modules\\nx\\src\\command-line\\run\\executor-utils.js',
    'D:\\Projects\\Own\\short-warden\\node_modules\\nx\\src\\project-graph\\utils\\project-configuration-utils.js',
    'D:\\Projects\\Own\\short-warden\\node_modules\\nx\\src\\utils\\package-json.js',
    'D:\\Projects\\Own\\short-warden\\node_modules\\nx\\src\\utils\\print-help.js',
    'D:\\Projects\\Own\\short-warden\\node_modules\\nx\\src\\command-line\\run\\run.js',
    'D:\\Projects\\Own\\short-warden\\node_modules\\nx\\bin\\run-executor.js'
  ]
}

Node.js v20.19.6

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

 NX   Cancelled running target serve for project my-nest-app (6s)

Package Manager Version

npm / pnpm

Operating System

  • [ ] macOS
  • [ ] Linux
  • [x] Windows
  • [ ] Other (Please specify)

Additional Information

I created a completely clean repository with a single APP. I did not change a single file manually. When I serve it, I get this error. All other commands work normally (build, for example).

node versions i tried: 22 / 24 /20

PoMaKoM avatar Dec 09 '25 23:12 PoMaKoM

same here : simple repo created here few minutes ago : https://github.com/soolidtech/newnx i'm working on WSL2, Node.js v22.14.0, package manager is PNPM

log on serve :

> nx run @newnx/newnx:serve:development

NX Daemon is not running. Node process will not restart automatically after file changes.
node:internal/modules/cjs/loader:1225
  const err = new Error(message);
              ^

Error: Cannot find module 'nx'
Require stack:
- /home/soolid/code/TBD/newnx/node_modules/@nx/js/src/executors/node/node.impl.js
- /home/soolid/code/TBD/newnx/node_modules/nx/src/config/schema-utils.js
- /home/soolid/code/TBD/newnx/node_modules/nx/src/command-line/run/executor-utils.js
- /home/soolid/code/TBD/newnx/node_modules/nx/src/project-graph/utils/project-configuration-utils.js
- /home/soolid/code/TBD/newnx/node_modules/nx/src/utils/package-json.js
- /home/soolid/code/TBD/newnx/node_modules/nx/src/utils/print-help.js
- /home/soolid/code/TBD/newnx/node_modules/nx/src/command-line/run/run.js
- /home/soolid/code/TBD/newnx/node_modules/nx/bin/run-executor.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1225:15)
    at Function.resolve (node:internal/modules/helpers:146:19)
    at /home/soolid/code/TBD/newnx/node_modules/@nx/js/src/executors/node/node.impl.js:211:70
    at new Promise (<anonymous>)
    at runBuild (/home/soolid/code/TBD/newnx/node_modules/@nx/js/src/executors/node/node.impl.js:210:35)
    at /home/soolid/code/TBD/newnx/node_modules/@nx/js/src/executors/node/node.impl.js:252:19
    at [Symbol.asyncIterator] (/home/soolid/code/TBD/newnx/node_modules/@nx/devkit/src/utils/async-iterable/create-async-iterable.js:12:13)
    at nodeExecutor (/home/soolid/code/TBD/newnx/node_modules/@nx/js/src/executors/node/node.impl.js:61:53)
    at nodeExecutor.next (<anonymous>)
    at getLastValueFromAsyncIterableIterator (/home/soolid/code/TBD/newnx/node_modules/nx/src/utils/async-iterator.js:15:34) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/soolid/code/TBD/newnx/node_modules/@nx/js/src/executors/node/node.impl.js',
    '/home/soolid/code/TBD/newnx/node_modules/nx/src/config/schema-utils.js',
    '/home/soolid/code/TBD/newnx/node_modules/nx/src/command-line/run/executor-utils.js',
    '/home/soolid/code/TBD/newnx/node_modules/nx/src/project-graph/utils/project-configuration-utils.js',
    '/home/soolid/code/TBD/newnx/node_modules/nx/src/utils/package-json.js',
    '/home/soolid/code/TBD/newnx/node_modules/nx/src/utils/print-help.js',
    '/home/soolid/code/TBD/newnx/node_modules/nx/src/command-line/run/run.js',
    '/home/soolid/code/TBD/newnx/node_modules/nx/bin/run-executor.js'
  ]
}

Node.js v22.14.0

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

 NX   Cancelled running target serve for project @newnx/newnx (3s)


View logs and run details at https://cloud.nx.app/runs/yBZ79n6f9C

 *  The terminal process "/bin/bash '-c', 'npx nx run @newnx/newnx:serve --configuration=development'" terminated with exit code: 130. 
 *  Terminal will be reused by tasks, press any key to close it. 

soolidtech avatar Dec 09 '25 23:12 soolidtech

I was just about to create an issue on this same thing. I've been battling with it all day thinking I must have been doing something wrong but the problem went away after I downgraded to 22.1.3.

Jesseekoh avatar Dec 10 '25 02:12 Jesseekoh

Same here when upgrading to 22.2

Le-G avatar Dec 10 '25 08:12 Le-G

Short summary: The bug does not depend on the platform (Windows/Linux). The bug does not depend on installation from scratch or migration to the current version.

The bug can be fixed by switching to a version other than 22.2.0.

P.s. I am very glad that I am not alone, because I could not find a single mention of this problem anywhere.

PoMaKoM avatar Dec 10 '25 12:12 PoMaKoM

The bug is also described at https://github.com/nrwl/nx/issues/33776

PoMaKoM avatar Dec 10 '25 22:12 PoMaKoM

Will be fixed in the 22.3 version

PikPakPik avatar Dec 13 '25 15:12 PikPakPik