-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Bug: Invoking a lambda function is giving me an error 'cannot find module' even though module exists #5415
Comments
Approaches I've tried:
|
Thanks for creating this issue, can you share your template and how your code is structured?
This is super interesting, do you see any changes in the artifacts within .aws-sam/ directory once you change the name of the resource? |
template.yaml
|
Facing the same issue on M1 Mac. Started initially well, then suddenly got the error with no code changes. Changed the name of the resource and starts working again. |
I also have this problem (also an M1 Mac), but unlike @dineshnagumothu , renaming the resource didn't work for me. I strongly suspect the issue is with the lambda runtime harness within the docker image; The error I get is :
But if I open a terminal session to the Docker container (which is left running), the The docker image seems to be this one:
|
In my case above, I discovered that I had an outdated version of the SAM CLI that was installed via homebrew, in addition to the one I'd installed via the MacOS package installer. After uninstalling both, and installing the latest (v1.97.0), debugging my lambda function works nicely for me. |
I’m running into a similar issue on my Mac, OS Ventura 13.6. It happens to all three hello-world ts apps, nodejs14, 16 and 18. One interesting thing is that after starting the app (any of the three), the first hit to the My sam cli is v1.97.0. I installed with the brew initially, same version, same error. Uninstall that and installed through pkg file. Same error. This error didn’t happened to me on the most popular python version of the Please let me know if there’s any fix for this issue. It doesn’t seems like there’s any obvious issue on my side. (If you know what I mean) Also removing images and changing resources name didn’t work. |
This error happens to me on the sample project:
No problem invoking and run the api for the plain js version |
The same problem applies to me, also mac m1 ventura 13.x. Unfortunately, image build and renaming don't help me either. I also tried reinstalling CLI, but that didn't make any difference for me. |
I'm also seeing this issue. On a Mac. Making nominal code changes sometimes gets it to go away, as does changing the resource name. --Edit with more details-- |
Also seeing this error on Mac M1 with this starter template. I previously also got it on the plain JS template, but not after updating the CLI to the latest version. A workaround for me seems to be running |
Same error on mac (m2) for me the api runs fine for some random amount of time then blows up with this error and requires me to kill and re-run |
Hi, I've tried to reproduce the issue using different init templates (nodejs18.x, ts app) but could not reproduce the same behavior. I installed the latest SAM CLI version (1.105.0) using the native PKG installer on a M1 Ventura 13.5.2 machine. Does the issue still occur in the latest version? If so, can you provide the steps/sample app to reproduce it for us to investigate this further?
|
I am on M1 Ventura 13.5.1 and was having the same issues described above. I had SAM CLI 1.106.0 installed through the GUI package installer, tried most or all the suggested approaches and nothing worked. I had the issue even with the starter hello world template. In my case, what ended up working for me was completely uninstalling SAM CLI and reinstalling it using brew. The installed version was the same (1.106.0). Not sure if what did the job was installing using brew or if the issue was with the GUI SAM CLI package installer I had used previously. Hope this is useful for someone else. |
Round back to this after a couple months. It’s working for me now after I reinstalled sam cli to 1.110.0 through brew. I also reinstalled Docker to the most up to date version, but I didn’t end up using the image version of the example instead I used the zip version. I’m using Hello World Node 18 sample. I didn’t test other Node versions sample since I only needed Node 18 to work for now. Hope this helps for others. |
I got it working by following the steps:
This issue occurring when using hello world example with typescript. |
I'm not sure if this is useful to anyone but I had a problem similar to this. I took an existing Typescript Node application I created, and tried to retrofit it so I could run it as an AWS Lambda function. The purpose of the application is to listen for new files being uploaded to a specific bucket, then process the file. The app uses My
I installed the AWS SAM CLI from the AWS website rather than using Homebrew (as AWS no longer maintains the Homebrew version), and Docker. I then created a
I then modified my
I also created a
Finally, I built my code and ran
After some trial and error here's what I discovered:
Obviously, copying Edit: Creating a Hello World example (the TypeScript version) using the AWS SAM CLI then modifying it for my needs seemed to fix the issue. See https://aws.amazon.com/blogs/compute/building-typescript-projects-with-aws-sam-cli/ on how to do this. |
I've raised a (possibly tangentially) related issue #7143 |
This did it for me, thank you @developerKumar! |
After building and starting the local sam server, I'm noticing after I run my lambda
GetBlocksByDateRangeFunction
, I get this error in the console.Steps to reproduce:
I'm not sure how I got this behavior to happen.
Observed result:
Expected result:
I'm expecting it to not return an error and not to say
Cannot Find Module
since the module does exist.Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Mac
sam --version
: SAM CLI, version 1.88.0The text was updated successfully, but these errors were encountered: