Nest serve error (22.2.0)
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
- Install and initialize nx 22.2.0
- nx add @nx/nest
- nx g @nx/nest:app apps/my-nest-app
- 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
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.
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.
Same here when upgrading to 22.2
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.
The bug is also described at https://github.com/nrwl/nx/issues/33776
Will be fixed in the 22.3 version