nx
nx copied to clipboard
`exec` not working in a Windows enviroment
Current Behavior
On Windows, nx exec can't find the binary to execute. From what we can see in the error logs, Nx is trying to resolve binaries in the wrong folder (not inside of ./node_modules/.bin/).
This is not an issue on macOS or Ubuntu. We've only tested this with pnpm.
Here is an example CI run, where macOS and Ubuntu pass, and Windows fails: https://github.com/mrmckeb/nx-repro/actions/runs/5461420103/attempts/1
| Description | Output |
|---|---|
echo $PWD |
D:\a\nx-repro\nx-repro |
pnpm which prettier |
D:\a\nx-repro\nx-repro\node_modules\.bin\prettier |
| Path Nx is trying to use | D:\a\nx-repro\prettier\bin-prettier.js |
I've re-run the same jobs with GitHub's debug logs in case that helps: https://github.com/mrmckeb/nx-repro/actions/runs/5461420103/attempts/2
Expected Behavior
nx exec should behave the same on Windows as it does on other operating systems.
GitHub Repo
https://github.com/mrmckeb/nx-repro
Steps to Reproduce
- Set up a tax with
nx exec -- [bin-name]. - Run that task on Windows.
Nx Report
Node : 20.3.1
OS : win32-x64
pnpm : 8.6.6
nx : 16.4.3
@nrwl/tao : 16.4.3
Failure Logs
> [email protected] prettier D:\a\nx-repro\nx-repro
> nx exec -- prettier -c .
> nx run nx-repro:prettier
> [email protected] prettier D:\a\nx-repro\nx-repro
> nx exec -- prettier -c .
node:internal/modules/cjs/loader:1075
throw err;
^
Error: Cannot find module 'D:\a\nx-repro\prettier\bin-prettier.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1072:15)
at Module._load (node:internal/modules/cjs/loader:925:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v20.3.1
ELIFECYCLE Command failed with exit code 1.
> NX Running target prettier for project nx-repro failed
Failed tasks:
- nx-repro:prettier
Hint: run the command with --verbose for more details.
ELIFECYCLE Command failed with exit code 1.
Error: Process completed with exit code 1.
Operating System
- [ ] macOS
- [ ] Linux
- [X] Windows
- [ ] Other (Please specify)
Additional Information
No response