Running into an error when importing mysql package

There’s a discussion here but the solution links to a url that’s broken:

✘ [ERROR] Cannot bundle Node.js built-in "events" imported from "node_modules/mysql/node_modules/readable-stream/lib/internal/streams/stream-browser.js". Consider disabling ssr.noExternal or remove the built-in dependency. [plugin vite:dep-pre-bundle]

    node_modules/vite/node_modules/esbuild/lib/main.js:1225:21:
   

That link is from a 3P dev - https://github.com/Weaverse/hydrogen-express-adapter-ts/blob/main/server.js

Maybe @Weaverse can help??

I no longer recommend using another server adapter, like Express, for the new version of Shopify Hydrogen. Instead, I suggest using only Oxygen for now. Keep in mind that Oxygen operates on Cloudflare Workers, which limits the Node APIs you can use. I recommend checking out the following database option recommended by Cloudflare: Connect to databases | Cloudflare Workers docs.

2 Likes

Got it thanks I will take a look at that.

1 Like

Yes I’m using oxygen btw.

Here come the dumb questions. I’m not super familiar with cloudflare - one of the great things about hydrogen/oxygen is how easily you can get things spun up without needing to know too much.

Will I be creating a cloudflare worker? I would think hydrogen is the cloudflare worker in this case. In which case I’m not sure how I need to configure wrangler.toml.

@Liam-Shopify is there any official guidance from the hydrogen team on how to connect to a database?