Slack Workflow Builder Steps from Apps tutorial -> ReferenceError: require is not defined

Hi,

I’m following the tutorial at Workflow Builder Steps from Apps | Slack

Glitch template: Glitch :・゚✧

I’m unable to verify my Request URL in Slack App Settings/Event Subscriptions which I think might be because the remixed code generates an error in the glitch logs:

ReferenceError: require is not defined

file:///app/index.js:1
const { App, WorkflowStep } = require("@slack/bolt");
ReferenceError: require is not defined
Jump Toat file:///app/index.js:1:31
at ModuleJob.run (internal/modules/esm/module_job.js:152:23)
at async Loader.import (internal/modules/esm/loader.js:166:24)
at async Object.loadESM (internal/process/esm_loader.js:68:5)

Any ideas what’s going on?

Thanks!

Rick

The error happens because the package type is declared as module in package.json ("type": "module").

You will need to define require in order to use it:

import {createRequire} from 'module'
const require = createRequire(import.meta.url)
1 Like