nx icon indicating copy to clipboard operation
nx copied to clipboard

Unable to build library with rollup

Open FFGFlash opened this issue 6 months ago • 1 comments

Current Behavior

Creating a new workspace with pnpm, typescript and wollup on windows fails to build.

Expected Behavior

For library to build.

GitHub Repo

No response

Steps to Reproduce

  1. Create a new workspace with pnpm dlx create-nx-workspace@latest
    • Choose anything for the name
    • Select none for stack
    • Select yes for prettier
    • Select Do it later for CI
    • Select No for remote caching
  2. Create a library package pnpm dlx nx@latest g @nx/js packages/test --publishable --importPath=@org/test
    • Select rollup
    • Select eslint
    • Select vitest
  3. Build library pnpm dlx nx@latest build test
    • Fails to build library

Nx Report

Node           : 23.9.0
OS             : win32-x64
Native Target  : x86_64-windows
pnpm           : 10.5.2

nx (global)        : 21.1.3
nx                 : 21.1.3
@nx/js             : 21.1.3
@nx/eslint         : 21.1.3
@nx/eslint-plugin  : 21.1.3
@nx/rollup         : 21.1.3
@nx/vite           : 21.1.3
@nx/web            : 21.1.3
typescript         : 5.7.3
---------------------------------------
Registered Plugins:
@nx/js/typescript
@nx/rollup/plugin
@nx/eslint/plugin
@nx/vite/plugin
---------------------------------------
Cache Usage: 0.00 B / 186.28 GB

Failure Logs

> nx run @org/test:build

> rollup -c rollup.config.cjs

[!] Error: ENOENT: no such file or directory, mkdir 'D:\Repositories\ffg-engine\tmp\D:\Repositories\ffg-engine\packages\test\build'
    at mkdirSync (node:fs:1361:26)
    at writeJsonFile (D:\Repositories\ffg-engine\node_modules\.pnpm\[email protected]_@swc-node+registe_e939b9b0833f2d74f42f4dee6024ac3f\node_modules\nx\src\utils\fileutils.js:58:29)
    at createTmpTsConfig (D:\Repositories\ffg-engine\node_modules\.pnpm\@[email protected]_@babel+traver_43e04274811eea60c682184a06811ac3\node_modules\@nx\js\src\utils\buildable-libs-utils.js:242:32)
    at withNx (D:\Repositories\ffg-engine\node_modules\.pnpm\@[email protected]_@babel+co_f03bf12d88ca9293717b862a3d514db3\node_modules\@nx\rollup\src\plugins\with-nx\with-nx.js:48:56)
    at Object.<anonymous> (D:\Repositories\ffg-engine\packages\test\rollup.config.cjs:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1734:14)
    at Object..js (node:internal/modules/cjs/loader:1899:10)
    at Module.load (node:internal/modules/cjs/loader:1469:32)
    at Function._load (node:internal/modules/cjs/loader:1286:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)


Warning: command "rollup -c rollup.config.cjs" exited with non-zero status code
———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Ran target build for project @org/test (1s)

   ×  1/1 failed
   √  0/1 succeeded [0 read from cache]

Package Manager Version

No response

Operating System

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

Additional Information

No response

FFGFlash avatar Jun 10 '25 09:06 FFGFlash

check this PR https://github.com/nrwl/nx/pull/31314

balmasich avatar Jun 10 '25 14:06 balmasich

any updates on this? or temporary solutions? @FrozenPandaz @FFGFlash

Mr-Jami avatar Jul 14 '25 07:07 Mr-Jami

any updates on this? or temporary solutions? @FrozenPandaz @FFGFlash

I'm still waiting for this to be fixed as well, @balmasich made a PR with a fix, but it still hasn't been approved to be apart of the main package. In the meantime I've been using Vite instead since it's built upon rollup which does work, kind of sucks because it's a bit overkill for what I wanted.

FFGFlash avatar Jul 16 '25 19:07 FFGFlash

Yeah, I had the same problem. My library build for nx/nest app failed to build on Windows. And on Linux, webpack failed to use that library. Do we have any temporary fixes while we wait for this issue to be resolved?

thankkien avatar Jul 22 '25 05:07 thankkien