I'm trying to build a web app in AWS lambda and upload it to an S3 bucket. For that, I utilize child process, which is working fine locally.
exec('cd /tmp/ && npm ci && ng build --prod="true"', (error, stderr, stdout) => {
if (error) {
console.log(error);
return reject(error);
}
});
I also tried using npm install instead of npm ci, in all cases it fails with the error:
"npm ERR! errno -30", "npm ERR! rofs EROFS: read-only file system, mkdir '/home/sbx_user1051'", "npm ERR! rofs Often virtualized file systems, or other file systems", "npm ERR! rofs that don't support symlinks, give this error.", "npm ERR! code EROFS", "npm ERR! syscall mkdir",
Command failed: cd /tmp/ && npm ci && ng build --prod="true"\nnpm ERR! code EROFS\nnpm ERR! syscall mkdir\nnpm ERR! path /home/sbx_user1051\nnpm ERR! errno -30\nnpm ERR! rofs EROFS: read-only file system, mkdir '/home/sbx_user1051'\nnpm ERR! rofs Often virtualized file systems, or other file systems\nnpm ERR! rofs that don't support symlinks, give this error.\nnpm ERR!
I understand that only the /tmp/ directory is writable in AWS Lambda. I just don't know how to tell npm to run in /tmp.
Any ideas?