Invoking sam local invoke returns an Unable to import module 'index': Error
See original GitHub issueI’m trying to play with the Hello-world example located in the samples of the repository. However upon invoking sam local invoke "HelloWorld" -e event.json
inside the directory where the index, template.yml and is located.
it automatically returns the ff:
START RequestId: e50a858c-69d8-16fc-02d3-70199542bc48 Version: $LATEST Unable to import module 'index': Error at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) END RequestId: e50a858c-69d8-16fc-02d3-70199542bc48 REPORT RequestId: e50a858c-69d8-16fc-02d3-70199542bc48 Duration: 31.25 ms Billed Duration: 0 ms Memory Size: 0 M
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:32 (2 by maintainers)
Top Results From Across the Web
AWS SAM Local and docker-lambda: keep getting Unable to ...
I'm trying to set up SAM Local with a Python lambda function and keep getting frustrated by the module import error in the...
Read more >Resolve "Unable to import module" errors from Python ... - AWS
I receive an "Unable to import module" error when I try to run my AWS Lambda code in Python. How do I resolve...
Read more >Dockerized Lambda: Invoking Sam Local Invoke Returns An ...
Dockerized lambda : Invoking sam local invoke returns an Unable to import module 'index': I am using AWS SAM and dockerized the lambdas....
Read more >How do I resolve the "Unable to import module" error I receive ...
How do I resolve the " Unable to import module " error I receive when I run Lambda code in Python?
Read more >awslabs/aws-sam-local - Gitter
Pulls code from Github, runs through sam validate and returns if the app passes the build or not.. We can even call sam...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
FWIW I recently started having this issue trying to test a function that was mounting fine previously. I reset docker to factory defaults, and when I next ran sam local was prompted to allow the drive to be shared and had to enter my password, now it’s working. Quite possibly caused by my password having changed since I allowed the drive share on docker.
Maybe I’m on the different case but I’ve resolved the similar
Unable to import module
issue on Windows, I hope sharing my workaround helps.I’m using the Windows subsystem for Linux but running Docker on Windows and using Docker on Linux by mapping the port. On WSL,
/mnt/c/
is mounted to Windows file system by default.The problem was that this
/mnt/c/blahblah
paths are not mounted when running a docker container on WSL, checking on this kind of commands:docker run -it -v /var/run/docker.sock:/var/run/docker.sock -v /mnt/c/Documents/current-working-directory:/data alpine
So I re-mounted the
C:\
to/c/
on Linux like this comment: https://github.com/Microsoft/WSL/issues/1854#issuecomment-291845122And I’ve invoked my function like this:
sam local invoke --docker-volume-basedir $(pwd -P) "Hello"
And it worked!