Skip to content

TypeError: ee.on is not a function #1832

@Stankman

Description

@Stankman

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
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
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
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions