dherault / dherault/serverless-offline

TypeError: ee.on is not a function

Open
#1,832 9 comments 5 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

**Current Behavior**

When running `sls offline` for a Serverless application using `serverless-offline` with the configuration below, an error occurs: `TypeError: ee.on is not a function`. This seems to prevent the expected startup of the local server.

**Sample Code**

- file: serverless.yml

```yaml
service: sls-test

provider:
name: aws
runtime: nodejs20.x

functions:
api:
handler: dist/lambda.handler
events:
- http:
path: /
method: ANY
- http:
path: '{proxy+}'
method: ANY

package:
exclude:
- node_modules/**

plugins:
- serverless-offline
```

- file: handler.js

```js
import serverlessExpress from '@codegenie/serverless-express';
import { NestFactory } from "@nestjs/core";
import { AppModule } from "./app.module";
import { Callback, Context, Handler } from 'aws-lambda';

let server : Handler;

export const handler = async (event: any, context: Context, callback: Callback) => {
if(!server) {
const app = await NestFactory.create(AppModule);
await app.init();

const expressApp = app.getHttpAdapter().getInstance();
server = serverlessExpress({
app: expressApp
});
}

return server(event, context, callback);
}
```

**Expected behavior/code**

The application should start without errors and expose the API endpoints locally using serverless-offline.

**Environment**

- `serverless` version: 4.4.7
- `serverless-offline` version: 14.3.3
- `node.js` version: v20.18.0
- `OS`: macOS 15.0.1

_optional, if you are using any of the following frameworks to invoke handlers_

- `nestJS` version: 10.4.5

**Possible Solution**

It could be helpful to check for compatibility issues with serverless-offline or dependencies like ee-first in conjunction with the current node.js version.

**Additional context/Screenshots**

Output when running sls offline:
```
[Error Logs...]
✖ TypeError: ee.on is not a function
...
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.