docker-lambda icon indicating copy to clipboard operation
docker-lambda copied to clipboard

Cannot find module '/var/task/index' on windows 7

Open CharlesJu1 opened this issue 7 years ago • 2 comments

I installed docker toolbox on windows 7. When I run docker run -v /d/projects/lambda/helloworld:/var/task lambci/lambda I got the following error

{"errorMessage":"Cannot find module '/var/task/index'","errorType":"Error","stackTrace":["Function.Module._load (module.js:276:25)","Module.require (module.js:353:17)","require (internal/module.js:12:17)"]}

I googled but could not find out the solution.

The docker file for lambci/lambda has

ENTRYPOINT ["/var/lang/bin/node", "--max-old-space-size=1228", "--max-semi-space-size=77", "--max-executable-size=154", "--expose-gc", "/var/runtime/node_modules/awslambda/index.js"]

But why it is looking for /var/task/index? And I mounted my source code folder to /var/task, why it can not find it?

CharlesJu1 avatar Dec 20 '17 03:12 CharlesJu1

I always cd to the directory and specify the function when run locally on windows

docker run -v %cd%:/var/task lambci/lambda:$platform $file.$function $event

e.g. docker run -v %cd%:/var/task lambci/lambda:python2.7 handler.dostuff {"data": ... }

dabruhce avatar Dec 27 '17 17:12 dabruhce

The $PWD bit was the problem for me (%cd%) in the respons above. I had to replace it with my absolute path using forward slashes.

MeStrak avatar Apr 27 '20 21:04 MeStrak