Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing Express.js ESM Support #39

Open
noahflk opened this issue Dec 7, 2024 · 2 comments
Open

Failing Express.js ESM Support #39

noahflk opened this issue Dec 7, 2024 · 2 comments

Comments

@noahflk
Copy link

noahflk commented Dec 7, 2024

Using this import:

import { serve } from "@upstash/workflow/express";

I get this error in an Express.js ESM app:

file:///XXX/node_modules/.pnpm/@[email protected]/node_modules/@upstash/workflow/chunk-ADOBNR4O.mjs:11
  throw Error('Dynamic require of "' + x + '" is not supported');
        ^

Error: Dynamic require of "path" is not supported
@noahflk noahflk changed the title Express.js ESM Support Failing Express.js ESM Support Dec 7, 2024
@manurana
Copy link

manurana commented Feb 7, 2025

Apologies if this is unrelated, but I am getting another ESM error while running this in AWS lambda.
I created my own handler using the serve from @upstash/workflow

   ReferenceError: __dirname is not defined in ES module scope
       at node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_@[email protected]_/node_modules/@jimp/plugin-print/dist/index.js (file:///xxxb/kbackend/.sst.config.1738925600291.mjs:230589:41)

The function is being bundled with esbuild before deploying, and the error shows up in the bundling

@priyanshuxdev
Copy link

hi noahflk, instead of directly importing the (serve) function using import statement
Use the snippet below -:

import { createRequire } from 'module';
const require = createRequire(import.meta.url)
const { serve } = require('@upstash/workflow/express');

hope it works : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants