- Newest
- Most votes
- Most comments
The error you're encountering suggests that AWS Lambda is unable to find the axios module, and it's looking for it in a directory that does not exist, such as 'opt/nodejs/axios'. This issue might be related to how you've bundled and deployed your Lambda function.
To resolve this issue, you can follow these steps:
-
Check Dependencies: Ensure that axios is properly added to your Lambda function's deployment package. In your AWS CDK project, make sure that axios is listed as a dependency in your package.json file.
-
Bundling: When you deploy a Lambda function with dependencies, it's essential to bundle the function with its dependencies. You can use tools like AWS SAM, Serverless Framework, or AWS CDK to help with bundling. Make sure your bundling process includes the node_modules directory.
-
Build Lambda Function: Before deploying, ensure that you build your Lambda function with the bundled dependencies and package it correctly.
Hi.
I think you created too complex a solution for this.
I recommend using Lambda NodeJsFunction.
Using it, you can install Axios on your root package json.
Lambda NodeJsFunction will get axios with esbuild
and create an appropriate build
All you have to do is to define entry point of your lambda handler
Relevant content
- asked a year ago
- asked 6 months ago
- AWS OFFICIALUpdated 4 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated a year ago
I found out if I remove the node_modules folder from git_ignore file, everything will work..., but it is a big folder, Can I really ignore it ?