BinaryBard
BinaryBard2mo ago

Persistent Node Built-in Resolution Errors (util, zlib, etc.) with apify-client Despite "use node";

Hey everyone, I'm running into a persistent issue trying to use apify-client (^2.12.2) within a Convex (^1.23.0) action on Windows 11. Even with "use node"; correctly placed, the convex dev build consistently fails with esbuild errors like: X [ERROR] Could not resolve "util" X [ERROR] Could not resolve "zlib" X [ERROR] Could not resolve "events" X [ERROR] Could not resolve "os" ✖ It looks like you are using Node APIs from a file without the "use node" directive. These errors point to apify-client and @apify/log dependencies. I've tried pretty much everything I can think of: Confirmed "use node"; is the very first line in the action file (convex/googleMaps/actions.ts) and any local files it imports that might need it (convex/googleMaps/utils.ts). Verified no non-Node files import the Node files. Added apify-client, @apify/log, util, zlib, events, os to experimentalExternalPackages in convex.json. Added nodeModules: true to convex.json. Did a full node_modules and package-lock.json deletion and npm install. Restarted convex dev countless times. Despite all this, the errors remain identical. It seems like the bundler isn't recognizing the Node platform context for this specific package, even with all the flags set. Has anyone else run into similar stubborn resolution issues with packages requiring Node built-ins, specifically apify-client or similar, on recent Convex versions? Any suggestions beyond the steps already tried would be greatly appreciated! Thanks!
2 Replies
Convex Bot
Convex Bot2mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
erquhart
erquhart2mo ago
Unless you're using an older version of Convex, try adding the apify dependencies (not all the node ones, just apify which imports them) to externalPackages (not experimentalExternalPackages): https://docs.convex.dev/functions/bundling#specifying-external-packages
Bundling | Convex Developer Hub
Bundling is the process of gathering, optimizing and transpiling the JS/TS

Did you find this page helpful?