I am trying to use Sharp library with worker for image optimization . Which gives me error even on changing to node.js environment (node_compat = true). Is there any way to make it work? Or any other library I can use for my task?
Error log when try to deploy:
Uncaught ReferenceError: __dirname is not defined
at worker.js:7625:32 in node_modules/sharp/lib/libvips.js
at worker.js:16:50 in __require2
at worker.js:7771:5 in node_modules/sharp/lib/constructor.js
at worker.js:16:50 in __require2
at worker.js:11841:17 in node_modules/sharp/lib/index.js
at worker.js:16:50 in __require2
at worker.js:11857:13
[code: 10021]