Hi Vercel Community,
I’m hoping someone can help me with a persistent runtime error on the Hobby plan. My serverless function (api/submit.ts) fails to initialize, and I’m completely stuck after several days of troubleshooting. Any help would be greatly appreciated.
Current Behavior
When the /api/submit endpoint is called, the function crashes instantly.
-
Browser Console: Shows a
500 (Internal Server Error). -
Vercel Function Log: Shows a fatal error immediately on startup:
TypeError: Cannot read properties of undefined (reading 'Context'). This happens when the code tries to runShopify.Context.initialize(...).
Expected Behavior
The function should initialize the @shopify/shopify-api library, find Shopify.Context, and proceed to run the endpoint logic (moderation, file upload, etc.).
Setup & Troubleshooting Steps Already Taken
Here is a summary of my setup and everything I’ve tried so far:
-
Dependencies Verified:
package.jsonis correctly set up with@shopify/shopify-apiv10.0.0 (andopenai,busboy,cors, etc.). Vercel’s build log confirms it installs them. -
Environment Variables: All 5 required keys (3 for Shopify, 1 for OpenAI, 1 for Shopify domain) are correctly configured in the Vercel project settings.
-
Import Methods Tried: We have tried multiple ways to import and initialize the library (
require, dynamicimport(), various import paths forrestResources), but they all result in the sameTypeError. -
Isolation Test: We deployed a minimal test function with only
require('@shopify/shopify-api')and aconsole.log(Shopify). The Vercel log showedTypeof Shopify: undefined. This confirms the library itself is not loading correctly in the Vercel runtime. -
New Project Test: I deployed the exact same codebase and environment variables to a brand new, clean Vercel project (
nodejs-serverless-function-express-ten-hazel-19). The exact same initialization error occurred, ruling out a corrupted project state.
-
Project URLs:
-
https://nodejs-serverless-function-express-richs-projects-7a3c1949.vercel.app/ -
https://nodejs-serverless-function-express-ten-hazel-19.vercel.app/
-
-
Framework: Node.js / Express
-
Environment: Hobby Plan
-
Library:
@shopify/shopify-apiv10.0.0
Given that the error happens immediately, persists across new projects, and fails even when only requiring the library, this strongly suggests an incompatibility or module-loading issue between the Vercel Node.js runtime and how @shopify/shopify-api v10.0.0 is packaged.
Has anyone else experienced this TypeError: Cannot read properties of undefined (reading 'Context') when using @shopify/shopify-api on Vercel? Is there a known workaround?
Thank you!