question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New AWS Lambda Example error: Failure: serverlessExpress is not a function

See original GitHub issue

Description

Sorry about the spam - Github server was spasming when i hit submit and it hung, i must have hit refresh. Apologies.

Due to the new guidelines about the deprecation of aws-serverless-express - i've updated my code to the new app.js example, as well as updated @slack/bolt to 3.2.0. I have the latest @vendia/serverless-express@3.4.0. Here is my npm list of serverless - (does it need to **not** be a dependency of aws-serverless-express@3.4.0 ?)
_user$ npm list @vendia/serverless-express
myl-app@1.0.0 /Library/WebServer/Documents/App/my-app
└─┬ aws-serverless-express@3.4.0
  └── @vendia/serverless-express@3.4.0_ 

– running my app code that worked before the updgrade, i receive this error:

**offline: POST /slack/events (Ξ»: slack)
offline: Failure: serverlessExpress is not a function
TypeError: serverlessExpress is not a function
    at Object.<anonymous> (/Library/WebServer/Documents/App/my-app/app.js:60:26)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at /Library/WebServer/Documents/App/my-app/node_modules/serverless-offline/dist/lambda/handler-runner/in-process-runner/InProcessRunner.js:145:133
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at InProcessRunner.run (/Library/WebServer/Documents/App/my-app/node_modules/serverless-offline/dist/lambda/handler-runner/in-process-runner/InProcessRunner.js:145:9)**

Thinking that it was my code that caused the issue, i just ran the exact code from here: https://github.com/slackapi/bolt-js/blob/main/examples/deploy-aws-lambda/app.js

Still getting the same error.

Here is the serverless local app start:

_Serverless: Deprecation warning: Starting with next major version, default value of provider.lambdaHashingVersion will be equal to "20201221"
            More Info: https://www.serverless.com/framework/docs/deprecations/#LAMBDA_HASHING_VERSION_V2
Serverless: Deprecation warning: Starting with next major version, API Gateway naming will be changed from "{stage}-{service}" to "{service}-{stage}".
            Set "provider.apiGateway.shouldStartNameWithService" to "true" to adapt to the new behavior now.
            More Info: https://www.serverless.com/framework/docs/deprecations/#AWS_API_GATEWAY_NAME_STARTING_WITH_SERVICE
offline: Starting Offline: dev/us-east-1.
offline: Offline [http for lambda] listening on http://localhost:3002
offline: Function names exposed for local invocation by aws-sdk:
           * slack: serverless-bolt-js-dev-slack

   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
   β”‚                                                                         β”‚
   β”‚   POST | http://localhost:3000/slack/events                             β”‚
   β”‚   POST | http://localhost:3000/2015-03-31/functions/slack/invocations   β”‚
   β”‚   GET  | http://localhost:3000/slack/install                            β”‚
   β”‚   POST | http://localhost:3000/2015-03-31/functions/slack/invocations   β”‚
   β”‚   GET  | http://localhost:3000/slack/oauth_redirect                     β”‚
   β”‚   POST | http://localhost:3000/2015-03-31/functions/slack/invocations   β”‚
   β”‚                                                                         β”‚
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

offline: [HTTP] server ready: http://localhost:3000 πŸš€
offline: 
offline: Enter "rp" to replay the last request_

Your help is greatly appreciated. Thank you very much for your attention πŸ˜ƒ Andy

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I’ve read and understood the Contributing guidelines and have done my best effort to follow them.
  • I’ve read and agree to the Code of Conduct.
  • I’ve searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: @slack/bolt 3.2.0 @vendia/serverless-express@3.4.0

node version: v12.18.3

OS version(s): mac os sierra 10.12.6 (16G2136)

Steps to reproduce:

1.Follow the steps here exactly: https://slack.dev/bolt-js/deployments/aws-lambda 2. 3.

Expected result:

Local app to process Slack request / input

Actual result:

Error processing the Slack request / input

offline: POST /slack/events (Ξ»: slack)
offline: Failure: serverlessExpress is not a function
TypeError: serverlessExpress is not a function
    at Object.<anonymous> (/Library/WebServer/Documents/HeyAxl/hey-axl-app/app.js:60:26)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at /Library/WebServer/Documents/HeyAxl/hey-axl-app/node_modules/serverless-offline/dist/lambda/handler-runner/in-process-runner/InProcessRunner.js:145:133
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at InProcessRunner.run (/Library/WebServer/Documents/HeyAxl/hey-axl-app/node_modules/serverless-offline/dist/lambda/handler-runner/in-process-runner/InProcessRunner.js:145:9)

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
avery100commented, Feb 19, 2021

Hi @mwbrooks, I had to finish my code for the night and so i reverted to the deprecated aws-serverless-express version of my code - got it all working that way for now. I have to switch hats and work on another app - i will try to confirm tomorrow or the day after. Thank you so much for figuring this out!

0reactions
mwbrookscommented, Feb 19, 2021

@avery100 No worries and thanks for taking the time to help us confirm the fix! πŸ‘ŠπŸ» I’ve merged PR #806, which updates the documentation and example app. I tested it locally and on AWS Lambda.

If you’ve reverted to the older approach, then you should be able to use @vendia/serverless-express@3.x.x because it uses the original .createServer and .proxy interface.

Otherwise, you can update your code to use the modern approach, which requires @vendia/serverless-express@4.x.x.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AWS Serverless Lambda + Angular - TypeError: express is not ...
I downloaded it and the serverless lambda deploy worked correctly. The example uses angular 8 but hopefully it is the same for 9....
Read more >
The Pros and Cons of AWS Serverless Express | by Allan Chua
This means that any attempt to store session-related state inside the API instance will cause failures in the lambda function. This is attributed...
Read more >
Top 5 aws-serverless-express Code Examples - Snyk
How to use aws-serverless-express - 10 common examples ... notFound('requested page not found'); }); // catch all error handling app.use((err, req, res,Β ...
Read more >
@vendia/serverless-express | Yarn - Package Manager
This library enables you to utilize AWS Lambda and Amazon API Gateway to respond to web and API requests using your existing Node.js...
Read more >
A Deep Dive into Serverless Tracing with AWS X Ray & Lambda
One drawback is not being able to respond with different 5XX errors to indicate varying issues. With this setup a lambda has to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found