Using node.js packages #1535
-
How can i use packages like: https://www.npmjs.com/package/sharp? Whenever i use them on the server-side the remix application crashes. Is there a way to use those? (best practice?) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @carstensbix. By default Hydrogen is meant to run on Oxygen, which is worker runtime environment. Worker runtimes (like Cloudflare, Vercel, and others) are not NodeJS, and do not provide the NodeJS APIs. Read more about the Oxygen runtime at: https://shopify.dev/docs/custom-storefronts/hydrogen/deployments/oxygen-runtime If you'd like to use NodeJS libraries, you can either try to pollyfill those Node APIs (potentially difficult and bug prone), or you could just not deploy to Oxygen at all. Instead, setup Hydrogen with Express or another NodeJS webserver. We provide an example on how to do this here: https://github.com/Shopify/hydrogen/tree/main/examples/express |
Beta Was this translation helpful? Give feedback.
Hi @carstensbix. By default Hydrogen is meant to run on Oxygen, which is worker runtime environment. Worker runtimes (like Cloudflare, Vercel, and others) are not NodeJS, and do not provide the NodeJS APIs. Read more about the Oxygen runtime at: https://shopify.dev/docs/custom-storefronts/hydrogen/deployments/oxygen-runtime
If you'd like to use NodeJS libraries, you can either try to pollyfill those Node APIs (potentially difficult and bug prone), or you could just not deploy to Oxygen at all. Instead, setup Hydrogen with Express or another NodeJS webserver. We provide an example on how to do this here: https://github.com/Shopify/hydrogen/tree/main/examples/express