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

Getting Error: Cannot find module when used with serverless-webpack s3 event lambda invokation. #276

Open
gghukasyan opened this issue May 25, 2021 · 3 comments

Comments

@gghukasyan
Copy link

When using serverless with typescript/webpack, all the code is being compiled into .webpack folder on my machine but the way the lambda function is being invoked, it is not looking into .webpack folder.
Error: Cannot find module '/Users/garegin/Projects/myproj/src/functions/s3-event-listener'
Require stack:

  • /Users/garegin/Projects/myproj/node_modules/serverless-s3-local/node_modules/serverless-offline/dist/lambda/handler-runner/in-process-runner/InProcessRunner.js
  • /Users/garegin/Projects/myproj/node_modules/serverless-s3-local/node_modules/serverless-offline/dist/lambda/handler-runner/in-process-runner/index.js
  • /Users/garegin/Projects/myproj/node_modules/serverless-s3-local/node_modules/serverless-offline/dist/lambda/handler-runner/HandlerRunner.js
  • /Users/garegin/Projects/myproj/node_modules/serverless-s3-local/node_modules/serverless-offline/dist/lambda/handler-runner/index.js
  • /Users/garegin/Projects/myproj/node_modules/serverless-s3-local/node_modules/serverless-offline/dist/lambda/LambdaFunction.js
  • /Users/garegin/Projects/myproj/node_modules/serverless-s3-local/node_modules/serverless-offline/dist/lambda/LambdaFunctionPool.js
  • /Users/garegin/Projects/myproj/node_modules/serverless-s3-local/node_modules/serverless-offline/dist/lambda/Lambda.js
  • /Users/garegin/Projects/myproj/node_modules/serverless-s3-local/node_modules/serverless-offline/dist/lambda/index.js
  • /Users/garegin/Projects/myproj/node_modules/serverless-s3-local/index.js
  • /Users/garegin/Projects/myproj/node_modules/serverless/lib/classes/PluginManager.js
  • /Users/garegin/Projects/myproj/node_modules/serverless/lib/Serverless.js
  • /Users/garegin/Projects/myproj/node_modules/serverless/scripts/serverless.js
  • /Users/garegin/Projects/myproj/node_modules/serverless/bin/serverless.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.resolve (internal/modules/cjs/helpers.js:94:19)
    at InProcessRunner.run (/Users/garegin/Projects/myproj/node_modules/serverless-s3-local/node_modules/serverless-offline/dist/lambda/handler-runner/in-process-runner/InProcessRunner.js:140:18)
    at HandlerRunner.run (/Users/garegin/Projects/myproj/node_modules/serverless-s3-local/node_modules/serverless-offline/dist/lambda/handler-runner/HandlerRunner.js:177:64)
    at LambdaFunction.runHandler (/Users/garegin/Projects/myproj/node_modules/serverless-s3-local/node_modules/serverless-offline/dist/lambda/LambdaFunction.js:355:20)
@gghukasyan gghukasyan changed the title Getting Error: Cannot find module when with with serverless-webpack s3 event lambda invokation. Getting Error: Cannot find module when used with serverless-webpack s3 event lambda invokation. May 25, 2021
@jonnyasmar
Copy link

Having the same issue here. Did you ever figure out a solution or workaround for this?

@jonnyasmar
Copy link

And just like that. Publicize your problem and the solution comes to mind right away 😅

Looks like you just need to ensure the serverless-webpack plugin declaration comes before serverless-s3-local, e.g.

plugins:
  - serverless-webpack
  - serverless-s3-local

@ar90n
Copy link
Owner

ar90n commented Jul 26, 2021

@gghukasyan
I'm sorry for my late reply. I didn't recognize your comment.

@jonnyasmar
Thank you for your great sharing of a workaround to this issue. It sounds great!

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

3 participants