nx
nx copied to clipboard
"nx serve" on Windows with node app (framework: none) crashes any time any time a source file is saved: "Command failed: taskkill /pid xxx /T /F | The process "xxx" not found."
Current Behavior
- I'm on a Windows machine
- I have a new empty node app (or any node app with more code)
- When generating the node app, I pick
framework = none
- When generating the node app, I pick
- While running
nx serve <appname>
... - If I save any of my source code
.ts
files (even without any changes to content),nx serve
crashes with an error fromtaskkill.exe
:
C:\my-monorepo-dir>nx serve nodeapp4 --verbose
> nx run nodeapp4:serve:development
Hello World
> NX Process exited with code 0, waiting for changes to restart...
...... ๐พ I save main.ts at this point ......
> NX File change detected. Restarting...
node:child_process:399
ex = new Error('Command failed: ' + cmd + '\n' + stderr);
^
Error: Command failed: taskkill /pid 16852 /T /F
ERROR: The process "16852" not found.
at ChildProcess.exithandler (node:child_process:399:12)
at ChildProcess.emit (node:events:520:28)
at maybeClose (node:internal/child_process:1092:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5) {
killed: false,
code: 128,
signal: null,
cmd: 'taskkill /pid 16852 /T /F'
}
โโโโโโโโโโโโโโโโโโโโโโโโโโโโ
> NX Running target serve for project nodeapp4 failed
Failed tasks:
- nodeapp4:serve:development
Hint: run the command with --verbose for more details.
C:\my-monorepo-dir>
- And I'm then sent back to the cmd.exe prompt
- Therefore I have to manually re-run
nx serve
ornx build
every single time I edit anything
Expected Behavior
- Don't crash
-
nx serve
should just keep running regardless of whattaskkill.exe
does
GitHub Repo
No response
Steps to Reproduce
All on a Windows machine:
- Create a new Node app with command:
nx g @nx/node:application nodeapp4 --e2eTestRunner=none
- For the "framework" question, pick "none"
- Run
nx serve nodeapp4
- Open
apps\nodeapp4\src\main.ts
in any basic editor, e.g. Notepad - Hit ctrl+s to save the file, you don't even need to do an edit
-
nx serve
crashes
Nx Report
> NX Report complete - copy this into the issue template
Node : 16.14.0
OS : win32 x64
npm : 9.6.5
Hasher : Native
nx (global) : 16.2.2
nx : 16.2.2
@nx/js : 16.2.2
@nx/jest : 16.2.2
@nx/linter : 16.2.2
@nx/workspace : 16.2.2
@nx/cypress : 16.2.2
@nx/devkit : 16.2.2
@nx/esbuild : 16.2.2
@nx/eslint-plugin : 16.2.2
@nx/express : 16.2.2
@nx/node : 16.2.2
@nx/react : 16.2.2
@nrwl/tao : 16.2.2
@nx/web : 16.2.2
@nx/webpack : 16.2.2
typescript : 5.0.4
Failure Logs
No response
Operating System
- [ ] macOS
- [ ] Linux
- [X] Windows
- [ ] Other (Please specify)
Additional Information
- Maybe it's related to the exitcode 128 from taskkill.exe? Perhaps some Nx code is not expecting that?
- I've previously seen such errors appear on screen in previous version of Nx, e.g. v15.* + v16.0.0... but
nx serve
would still continue to run, rather than just crashing entirely - It started crashing entirely when I upgraded from v16.0.0 -> v16.2.1, and persists on v16.2.2
I also have this issue. I have several node.js apps that are just scripts that run (no servers or anything to kill).
node:internal/errors:868
const err = new Error(message);
^
Error: Command failed: taskkill /pid 1804 /T /F
ERROR: The process "1804" not found.
at ChildProcess.exithandler (node:child_process:419:12)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1091:16)
at ChildProcess._handle.onexit (node:internal/child_process:302:5) {
code: 128,
killed: false,
signal: null,
cmd: 'taskkill /pid 1804 /T /F'
}
I am having this issue as well. Seems to happen more often when I make back to back changes before the processes have been restarted.
In my example:
- NestJS app is running
- Change made in NestJS app files
- File change detected. Restarting...
- Quickly make an additional change before the restart is complete
- Error: Command failed: Taskkill /pid ##### /T /F
Same story, error appears after upgrade to 16.3.2
.
Same problem. see #17208
Any update on this? It's very annoying having to build with "nx build app --watch" and then manually running the node.js script.
- I just upgraded from Nx 16.3.2 -> 16.6.0
- โ๏ธ Looks like this is fixed for my setup
- Anyone else who was experiencing the issue:
- Can you please upgrade
- And confirm back whether it's fixed for you too?
I can confirm it is working as expected.
However, it is quite slow compared to the past. it was lightning fast for my node + typescript, now it takes 5-10 seconds to work. I'm also not getting all output from my processes being forwarded to the console and am forced to run nx build project --watch
and node dist/apps/project/main.js
to see what I used to. Waiting to see if this gets fixed magically before reporting.
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.