node.jsamazon-web-servicesaws-lambdaclaudiajsclaudia.js

Unable to import module 'index': Error in aws cloud watch logs while using claudia.js


Unable to import module 'index': Error in aws cloud watch logs. upload lambda using claudia works fine but api does not work and cloud watch logs displays following errors:

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)
at Object.<anonymous> (/var/task/node_modules/request/request.js:12:21)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)

Solution

  • I have some code that only works in local node version (so it passes validation locally), but fails once it goes to server version. use nvm to run node locally for lambda projects and you'll catch those errors before deployment so running : "npm install npm" in project directory solves the issue. then uploaded that again to aws using claudia. all works fine.

    thanks Gojko Adzic.