Using require in AWS lambda functions

Rohan Hadnum picture Rohan Hadnum · Jan 19, 2017 · Viewed 8k times · Source

I am currently researching AWS lambda functions and I can't find anywhere if I can use the require statement in them so that I can use other, non-lambda functions. I know about zipping the node modules folder but this doesn't help me here as I don't intend to use a node module, thanks for any answers!

Answer

Justin Niessner picture Justin Niessner · Jan 19, 2017

Yes, you can. You just have to ensure that the node_modules folder is uploaded as part of your package (you won't be able to use the console editor). You can read more details on the AWS Blog:

Using Packages and Native nodejs Modules in AWS Lambda