Skip to content

Cannot use 3d party libraries #125

@purefan

Description

@purefan

Hello,

I am unable to run a local lambda that relies on third party libraries, for example the redis one. The error I get is:

Unable to import module 'index'

For troubleshooting I:

  • Started sam local with debug enabled (sam local start-api--template notification.sam.yml --debug-port 5858)
  • Sent a curl request
  • Attached VSCode debugger which was probably not needed.
  • Found the docker container that spawned (docker ps and there was only one)
  • Attached an interactive shell to that container (docker exec -it <machine_alias> bash)
  • And tried to find the node_modules for my lambda, it wasn't in the execution folder (where my index.js was) and couldn't find it anywhere else.

I also tried with the static-dir flag (sam local start-api--template notification.sam.yml --debug-port 5858 --static-dir node_modules) but didn't see any difference.

I think sam local takes all *.js files in the lambda root but ignores the package.json file and the node_modules folder. Can someone please let me know if Im doing something wrong or if this perhaps is expected behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    blocked/more-info-neededMore info is needed from the requester. If no response in 14 days, it will become stale.type/featureFeature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions