Module initiation error (Object.fs.mkdirSync) while deploying node.js

I am trying to deploy an express app to Lambda using the serverless framework. I get the following error.

I tried a sample project, still the same issue…

Any pointers greatly appreciated.

START RequestId: ae1784c5-e0ec-11e7-b9d7-df8494a1e1b0 Version: $LATEST
module initialization error: Error
at Error (native)
at Object.fs.mkdirSync (fs.js:923:18)
at Object.mkdirsSync (/var/task/node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js:29:9)
at ensurePath (/var/task/node_modules/keystone/lib/storage/adapters/fs/index.js:32:7)
at new FSAdapter (/var/task/node_modules/keystone/lib/storage/adapters/fs/index.js:47:2)
at new Storage (/var/task/node_modules/keystone/lib/storage/index.js:100:17)
at Object.<anonymous> (/var/task/models/File.js:7:15)
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)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at /var/task/node_modules/keystone/index.js:196:23
at Array.forEach (native)
END RequestId: ae1784c5-e0ec-11e7-b9d7-df8494a1e1b0

Just to be clear, if you’re getting a Lambda error (in CloudWatch Logs) then you have deployed the service successfully, it’s just not running.

Without knowing anything about keystone, my guess would be that it’s trying to make a directory outside of /tmp - in the Lambda container you can only write to /tmp, everywhere else is readonly.