0
votes

I am trying to deploy an existing node js application using serverless on AWS infrastructure.

my yaml is like :

service: todo-app-api
provider:
  name: aws
  runtime: nodejs10.x

functions:
     app:
        handler: server.run
        events:
          - http:
              path: /
              method: ANY
              cors: false 
          - http:
              path: /{proxy+}
              method: ANY
              cors: false
plugins:
  - serverless-offline

SLS deploy works fine and it creates lambda and other resources well. But when invoking that getting internal server error, when I see aws logs it gives error details as

    "errorType": "Error",
    "errorMessage": "Unsupported framework",
    "stack": [
        "Error: Unsupported framework",
        "    at getFramework (/var/task/node_modules/serverless-http/lib/framework/get-framework.js:69:9)",
        "    at module.exports (/var/task/node_modules/serverless-http/serverless-http.js:14:21)",
        "    at Object.<anonymous> (/var/task/server.js:31:22)",
        "    at Module._compile (internal/modules/cjs/loader.js:778:30)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)",
        "    at Module.load (internal/modules/cjs/loader.js:653:32)",
        "    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)",
        "    at Function.Module._load (internal/modules/cjs/loader.js:585:3)",
        "    at Module.require (internal/modules/cjs/loader.js:692:17)",
        "    at require (internal/modules/cjs/helpers.js:25:18)",
        "    at _tryRequire (/var/runtime/UserFunction.js:75:12)",
        "    at _loadUserApp (/var/runtime/UserFunction.js:95:12)",
        "    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
        "    at Object.<anonymous> (/var/runtime/index.js:45:30)",
        "    at Module._compile (internal/modules/cjs/loader.js:778:30)",
        "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)"
    ]
}

can somebody tell me if anything wrong I have done?

Thanks In Advance.

2
Do you have a server.js file inside the same directory as your serverless.yaml, and does it include a line like module.exports.run = (event, context, callback) => { ? - Pat Needham

2 Answers

1
votes

I had the same problem and even opened an issue in the official repo. Everything was because I had in my serverless.yml:

plugins:
  - serverless-http # <---- delete this line
  - serverless-offline

I don't really know how it got there but deleting it solved my problem. I hope it helps and good luck :-)

0
votes

It was actually problem at my end. code in my server.js file was like

module.exports.run = sls(app_1); instead of

module.exports.run = sls(app_1.default);

Also in my app.js file exports.default = new App().app;

My code is working fine now.

Thanks