Open
Description
Current Behavior
When building libraries using Nx with custom Rollup configs (rollup.config.cjs) and the official withNx() helper, the build works fine on macOS/Linux but fails on Windows with an error related to invalid temporary directories.
Error: ENOENT: no such file or directory, mkdir 'Ç:\Users\myuser\Projects\nx-project\tmp\C:\Users\myuser\Projects\nx-project\libs\ui-comp\button\build'
Workaround
Setting buildLibsFromSource: true in the options passed to withNx() avoids the issue:
withNx({ ..., buildLibsFromSource: true, });
However, this disables Nx's library build cache, resulting in slower builds and losing incremental build benefits.
Expected Behavior
- Nx should either:
- Normalize or reject absolute outputPath values for Windows, or
- Sanitize paths internally to avoid joining tmp with an absolute Windows path.
- Users should be able to use absolute outputPath safely without disabling caching.
GitHub Repo
No response
Steps to Reproduce
- Use Nx workspace with a library containing rollup.config.cjs using withNx().
- Set outputPath to './dist', main to './src/index.ts' and tsConfig to './tsconfig/lib.json'
- Run
npx nx run-many -t build
on Windows. - Observe the mkdir error related to the invalid tmp\C:... path
Nx Report
Node: 22.15.0
OS: win32-x64
Native Target: x86_64-windows
npm: 10.9.2
nx: 21.2.0
@nx/js: 21.2.0
@nx/jest: 21.2.0
@nx/eslint: 21.2.0
@nx/workspace: 21.2.0
@nx/cypress: 21.2.0
@nx/devkit: 21.2.0
@nx/eslint-plugin: 21.2.0
@nx/module-federation: 21.2.0
@nx/next: 21.2.0
@nx/react: 21.2.0
@nx/rollup: 21.2.0
@nx/storybook: 21.2.0
@nx/vite: 21.2.0
@nx/web: 21.2.0
@nx/webpack: 21.2.0
typescript: 5.8.3
-----------------------------
Registered Plugins:
@nx/js/typescript
@nx/next/plugin
@nx/jest/plugin
@nx/eslint/plugin
@nx/react/router-plugin
@nx/rollup/plugin
@nx/storybook/plugin
------------------------------
Cache Usage: 4.60 MB/22.36 GB
Failure Logs
Package Manager Version
No response
Operating System
- macOS
- Linux
- Windows
- Other (Please specify)
Additional Information
OS: Windows 11 (tested)