Module not found when using Lambda Layer (node js, webpack)

Hi, I’m new to this, so this may be simple thing.

I have a simple lambda. In it I npm i axios --save, and in my code, I require(axios). This works great.

Now I want to extract axios into a layer so I can use it in other lambdas. I follow all steps, when deploying, I see the layer, and the contents of the .zip make sense. This is the yml config:

layers: thirdParty: path: src/layers/thirdParty description: All 3rd party libraries used by user-service

and for the lambda function:

funcName: handler: src/handlers/funcName.handler layers: - { Ref: ThirdPartyLambdaLayer }
I also npm uninstall axios --save from the function, as the hope is, it’ll pick it up from the layer.

And it might, but when I try to sls deploy, I get an error that axios module cannot be found - seems like webpack can’t locate the module because it has been removed from the function itself, and is unaware of the thirdParty layer.

Any ideas for how to fix this?

Thank you!