node_module errors with AWS lambda, what's the best practice for dependcies? -


i've been trying convert , deploy 1 of our node.js apps lambda function , have been having problems node_modules dependencies - saying can't find modules. started creating package.json, npm install dependencies locally copy node modules folder lambda.

for instance have project requires sequelize , convict , have been getting errors saying cannot find moment module sub-dependency. see moment included in root of node_modules not included in sub folder under sequelize module.

however, project runs fine locally. difference in lambda , what's best practice deploying long list of node modules - copy of node_modules folder? on of other simpler projects have, small amount of node_modules can copied no problems.

 {   "errormessage": "cannot find module 'moment'",   "errortype": "error",   "stacktrace": [     "function.module._resolvefilename (module.js:338:15)",     "function.module._load (module.js:280:25)",     "module.require (module.js:364:17)",     "require (module.js:380:17)",     "version (/var/task/node_modules/sequelize/node_modules/moment-timezone/moment-timezone.js:14:28)",     "object. (/var/task/node_modules/sequelize/node_modules/moment-timezone/moment-timezone.js:18:2)",     "module._compile (module.js:456:26)",     "object.module._extensions..js (module.js:474:10)",     "module.load (module.js:356:32)",     "function.module._load (module.js:312:12)"   ] } 

this sounds me issue caused different versions of npm. running same version of nodejs locally used lambda (ie. v0.10.36)?

depending on version of npm you're using install modules locally, node_modules directory's contents laid out differently (mainly in order de-duplicate things), , may why dependencies can't find dependencies in lambda.

after bit of digging, sounds clean install (ie. rm node_modules directory , run npm install) might clean things you. reason why seems npm doesn't install sub-dependencies if they're present @ top level (ie. installed moment before sequelize, etc).


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

apache - setting document root in antoher partition on ubuntu -