Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot find module 's_index' when serverless enterprise is enabled #47

Open
artworx opened this issue Nov 9, 2020 · 4 comments

Comments

@artworx
Copy link

artworx commented Nov 9, 2020

This is my serverless.yml file:

...
 functions:
    index:
      handler: dist/index.handler
...

The deployed Lamba's entry point gets set to s_index.handler, but when serverless-plugin-tree-shake is enabled, that file is not present in the deployment.

  Your Environment Information ---------------------------
     Operating System:          linux
     Node Version:              12.18.1
     Framework Version:         2.9.0 (standalone)
     Plugin Version:            4.1.1
     SDK Version:               2.3.2
     Components Version:        3.2.7
@sergioramos
Copy link
Owner

thanks for the report, I'm a bit busy right now, but I'll check this out once I have some time.

One thing to check: do you have any plugin compiling the files into dist/index.js? If so, is that step happening when you add serverless-plugin-tree-shake?

@artworx
Copy link
Author

artworx commented Nov 10, 2020

I don't have any extra plugins for compiling

This is the minimal serverless.yml I used to reproduce it.

org: artworx
app: demo
service: lambda-demo

provider:
  name: aws
  runtime: nodejs12.x
  region: eu-central-1
  stage: dev

plugins
  - serverless-plugin-tree-shake

functions:
  hello:
    handler: handler.main

As soon as I add org and app keys to serverless.yml, the handler in cloud formation is s_handler.

# .serverless/serverless-state.json

          "HelloLambdaFunction": {
            "Type": "AWS::Lambda::Function",
            "Properties": {
              "Code": {
                "S3Bucket": {
                  "Ref": "ServerlessDeploymentBucket"
                },
                "S3Key": "serverless/...
              },
              "Handler": "s_hello.handler",

If I remove the serverless-plugin-tree-shake, the packaged zip file includes s_handler.

edit: without the plugin:

Archive:  .serverless/demo-lambda.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
     158  Defl:N      123  22% 1980-01-01 00:00 9d69e4e5  handler.js
     177  Defl:N      139  22% 1980-01-01 00:00 550be662  node_modules/.bin/components
    1542  Defl:N      694  55% 1980-01-01 00:00 6339c529  node_modules/.bin/nft
  272492  Defl:N    83162  70% 1980-01-01 00:00 85af2074  package-lock.json
     431  Defl:N      263  39% 1980-01-01 00:00 71d54573  package.json
     910  Defl:N      490  46% 1980-01-01 00:00 79514b6d  s_hello.js
  350564  Defl:N   121712  65% 1980-01-01 00:00 0fb2e8c6  serverless_sdk/index.js
--------          -------  ---                            -------
  626274           206583  67%                            7 files

with the plugin enabled:

Archive:  .serverless/demo-lambda.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
     158  Defl:N      123  22% 1980-01-01 00:00 9d69e4e5  handler.js
     431  Defl:N      263  39% 1980-01-01 00:00 71d54573  package.json
--------          -------  ---                            -------
     589              386  35%                            2 files

Original directory:

$ tree
.
├── handler.js
├── package.json
├── package-lock.json
└── serverless.yml

@sergioramos
Copy link
Owner

But notice that in your second snippet you no longer have the dist/ in the handler. Any reason why?

@artworx
Copy link
Author

artworx commented Nov 10, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants