I’m working on a project that deploys to cloudflare workers, it uses a dynamically linked executable. Works fine in a docker container. I’m new to using nix shells and I was wondering if anyone knows the best way to get this working.
This can be reproed by running npm create cloudflare@latest -- my-next-app --framework=next
Error: write EPIPE
at afterWriteDispatched (node:internal/stream_base_commons:159:15)
at writeGeneric (node:internal/stream_base_commons:150:3)
at Socket._writeGeneric (node:net:971:11)
at Socket._write (node:net:983:8)
at writeOrBuffer (node:internal/streams/writable:572:12)
at _write (node:internal/streams/writable:501:10)
at Writable.write (node:internal/streams/writable:510:10)
at Runtime.updateConfig (/home/ncrmro/code/ncrmro/meze/node_modules/.pnpm/miniflare@4.20250712.1/node_modules/miniflare/dist/src/index.js:15817:26)
at async #assembleAndUpdateConfig (/home/ncrmro/code/ncrmro/meze/node_modules/.pnpm/miniflare@4.20250712.1/node_modules/miniflare/dist/src/index.js:25189:30)
at async Mutex.runWith (/home/ncrmro/code/ncrmro/meze/node_modules/.pnpm/miniflare@4.20250712.1/node_modules/miniflare/dist/src/index.js:6235:48) {
errno: -32,
code: 'EPIPE',
syscall: 'write'
}
I just came across this issue and found a solution. I’m not sure if it’s the best one but it seemed to work well for me.I am using direnv with flakes.In my main nixos config I added this:
programs.nix-ld.enable = true;
Then inside my mkShell function in the project flake I added this:
Don’t use nix-ld if you are new to all of this. Some of us think nobody should use nix-ld ever, but if you are going to use it you should at least be familiar enough with Nix to understand what you’re giving up when you do.
The ultimate solution is ‘don’t do this’ — that is, don’t try to use packages from NPM directly, and instead source them from Nixpkgs or learn to package them yourself the right way — but people who ask this question generally aren’t equipped to do that yet. A ‘solution’ that is strictly better than using nix-ld is to change NIX_LD_LIBRARY_PATH to LD_LIBRARY_PATH in the example you posted and stop using nix-ld. It’s not the ultimate solution because messing with LD_LIBRARY_PATH can get you into hot water sometimes, but it’s the same hot water that nix-ld would get you into, and at least this way you aren’t polluting your entire system with impurity as nix-ld does.