dherault / dherault/serverless-offline

ERR_REQUIRE_ESM (v13.10)

Open
#1,890 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.3k
Forks
811
Avg merge
2d 4h
Merged PRs (30d)
3

Description

## Bug Report

Sorry, this doesn't quite follow the issue format-- I'm on serverless 3.40.0, and have had serverless-offline ^13.6.0 in my package.json. Additionally, I'm still on outdated Node v18.20.6, so I apologize if any of these cause this "issue" to be irrelevant. However, I've confirmed that serverless-offline 13.9.0 works completely fine, while 13.10.0 gives me error ERR_REQUIRE_ESM. I'll be pinning my deps to 13.9.0, but just wanted to raise this issue in case others were running into it.

**Current Behavior**

Getting error ERR_REQUIRE_ESM with v13.10.0 when running `serverless offline start`

**This works fine**
- package.json `"serverless-offline": "~13.9.0"`
- rm -rf node_modules
- rm package-lock.json
- npm install
- confirm node-modules/serverless-offline/package.json shows `13.9.0`
- `serverless offline start --stage local`

**This throws ERR_REQUIRE_ESM error**
- package.json `"serverless-offline": "13.10.0"`
- rm -rf node_modules
- rm package-lock.json
- npm install
- confirm node-modules/serverless-offline/package.json shows `13.10.0`
- `serverless offline start --stage local`
- get error below

```
Error [ERR_REQUIRE_ESM]: require() of ES Module /some-path/infra/serverless/system/node_modules/serverless-offline/src/index.js not supported.
Instead change the require of index.js in null to a dynamic import() which is available in all CommonJS modules.
at Object. (/some-path/infra/serverless/system/node_modules/serverless-offline/src/index.cjs:3:18)
at async module.exports (/some-path/infra/serverless/system/node_modules/serverless/lib/utils/require-with-import-fallback.js:10:15)
at async PluginManager.resolveServicePlugins (/some-path/infra/serverless/system/node_modules/serverless/lib/classes/plugin-manager.js:198:18)
at async PluginManager.loadAllPlugins (/some-path/infra/serverless/system/node_modules/serverless/lib/classes/plugin-manager.js:136:36)
at async Serverless.init (/some-path/infra/serverless/system/node_modules/serverless/lib/serverless.js:146:5)
at async /some-path/infra/serverless/system/node_modules/serverless/scripts/serverless.js:601:7
```

**Expected behavior/code**

I'd expect that upgrading the minor version won't cause a breaking change.

**Environment**

- `serverless` version: v3.40.0
- `serverless-offline` version: v13.10.0 (~v13.6.0)
- `node.js` version: v18.20.6
- `OS`: macOS 15.3.2

**Possible Solution**

For a temporary workaround, just pin version 13.9.0.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with serverless 3.40.0, serverless-offline 13.10.0, and Node 18.20.6, comparing it with 13.9.0. Start by reading node_modules/serverless-offline/src/index.cjs and src/index.js, then verify the plugin loads successfully through `serverless offline start --stage local` without ERR_REQUIRE_ESM.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.