serverless-webpack: No matching handler found for 'handler'. Check your service definition
I just upgraded from serverless-webpack 2.0.0 to 2.2.0 and got the following error. It was working perfectly with the previous version.
No matching handler found for 'handler'. Check your service definition
Is there anything wrong in my configuration?
service: my_service
provider:
...
custom:
webpack: webpack.config.serverless.js
functions:
my_function:
handler: handler.my_function
events:
...
plugins:
- serverless-webpack
FYI I’m on serverless latest (as of today: 1.18.1)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 23 (13 by maintainers)
Ok, found. The problem is that
slsw.lib.entriesdoes not contain an array, but the object{ 'src/server/handler': './src/server/handler.js' }If I just use the previous config, it works fine
So, at the end, the fix was to set the path in the handler definition:
Ok. I think the missing path in the function definition is the problem. The function definition should define the path - otherwise you’d also get issues with other plugins that need to find the handler. The problem is, that Serverless (the framework) is completely unaware of the handler location in your case.
So, please change the handler definition in your serverless.yml.
… and the good thing: With 2.2.0 you now do not have to set the entries manually anymore in your webpack config. Just use:
Then you can add functions to your service without changing the config again.
@HyperBrain thanks again for your help.
I’ve experimented further, using your
v3.0.0-individual-packagingbranch andserverless-plugin-optimize. Here’s the repo.Adding the plugin does reduce the time to deploy, but once deployed the Lambda errors with:
It’s probably that my configuration with
serverless-plugin-optimizeis incorrect. Will try to get it working.Hope that’s useful 😬
@HyperBrain thanks for all your help! I have a working set-up now:
and followed your suggestion of using webpack
^3.0.0as a dependency.I’ll reach out to the maintainer of
serverless-babel-starterand see if they’re open to a PR 👍Thanks again!
Glad to hear that it now works 👍
By the way, I’m using yarn to freeze dependencies. I noticed while trying several configurations that I can get the issue with 2.0.0 too. It looks like the problem appears with the upgrade of an inner dependency, somewhere.