Skip to content

ERR_REQUIRE_ESM: Vercel/Node launcher require()s /.well-known/workflow/v1/step/route.js but route is ESM ("type": "module") #1449

@andreisocaciu

Description

@andreisocaciu

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)

  1. Next.js 16.2 app with "type": "module".
  2. Install and configure latest workflow with the standard App Router /.well-known/workflow/v1/step route.
  3. Deploy to Vercel and start a workflow to hit the step endpoint.
  4. Observe ERR_REQUIRE_ESM in function logs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions