External Library Relies on child_process and fs
A package that I intend to use on my worker, sharp, requires access child_process and fs.
I know that Workers come with these, but require the "node" prefix to be used when importing them, which the sharp package does not do.
Is there any way to fix this? The only thing I can think of is building sharp from the original repo and then importing it, but that feels excessive?
1 Reply
Workers don't have those no, not even with nodejs_compat flag:
https://developers.cloudflare.com/workers/runtime-apis/nodejs/
Workers run in V8 (same JS Engine as Chrome) as Isolates. They fundamentally cannot launch child processes, nor do they have a file system. It wouldn't work regardless
Cloudflare Docs
Node.js compatibility · Cloudflare Workers docs
Implemented Node.js runtime APIs and enablement instructions for your Worker project.