-
Notifications
You must be signed in to change notification settings - Fork 221
ERR_REQUIRE_ESM: Vercel/Node launcher require()s /.well-known/workflow/v1/step/route.js but route is ESM ("type": "module") #1449
Copy link
Copy link
Open
Description
Description
On Next.js 16.2 with the latest workflow packages, the step webhook route fails at runtime on Vercel (Node serverless).
Environment
- Next.js: 16.2
- workflow: 4.2.0-beta.71
- Runtime: Vercel
- App
package.json:"type": "module"
Error
Failed to handle /.well-known/workflow/v1/step Error: require() of ES Module /var/task/.next/server/app/.well-known/workflow/v1/step/route.js from /var/task/___next_launcher.cjs not supported.
route.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename route.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "commonjs" in /var/task/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).
at <unknown> (../../opt/rust/nodejs.js:2:13531)
at Function.pn (../../opt/rust/nodejs.js:2:13909)
at Xe.e.<computed>.Ye._load (../../opt/rust/nodejs.js:2:13501) {
code: 'ERR_REQUIRE_ESM'
}
Expected behavior
The /.well-known/workflow/v1/step handler should load correctly on Vercel.
Actual behavior
Request handling for that route throws ERR_REQUIRE_ESM and step execution breaks.
Notes
- Workaround we’re testing: pinning Next to 16.1.6 appears to avoid the issue.
Reproduction (minimal)
- Next.js 16.2 app with
"type": "module". - Install and configure latest
workflowwith the standard App Router/.well-known/workflow/v1/steproute. - Deploy to Vercel and start a workflow to hit the step endpoint.
- Observe
ERR_REQUIRE_ESMin function logs.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels