1 Answer
- Newest
- Most votes
- Most comments
2
Check that your zip file has the index.js file at the root of the zip file (it's easy to accidentally end up with it in a subdirectory).
You want to ensure you are just zipping up the files and not the directory - e.g. zip lambda.zip index.js
answered 9 months ago
Relevant content
- asked 5 months ago
- asked 8 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
Thanks for the response!
When I read this I was 'oh duh' because I'd completely done as you'd said (zipping the directory not the files.)
Sadly, correctly zipping the files, hasn't resolved the issue, same error...
This is the error in its entirety: { "errorType": "Runtime.ImportModuleError", "errorMessage": "Error: Cannot find module 'index'\nRequire stack:\n- /var/runtime/index.mjs", "stack": [ "Runtime.ImportModuleError: Error: Cannot find module 'index'", "Require stack:", "- /var/runtime/index.mjs", " at _loadUserApp (file:///var/runtime/index.mjs:1087:17)", " at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)", " at async start (file:///var/runtime/index.mjs:1282:23)", " at async file:///var/runtime/index.mjs:1288:1" ] }
To my (admittedly amateur) eye, it looks like something is still pointing at the old 'hello-world' set-up, but... it's only a guess.
CharlieM - Can you see the code source on the console once you have uploaded? If so you should see a folder with your lambda's name and then index.js immediately below it. If you can't see the source because you have dependencies that are making it too big, try to just zip up the index.js on its own and check the structure looks correct.
Thank you! In fact your initial advice was correct, and my initial fix was correct. What I hadn't realised was that when I updated the zip, I had to recopy it into the Lambda function. Now working as expected.