0
votes

I am trying to run npm install from inside AWS Lambda. But I'm getting the below error. Setting --prefix to "/tmp" doesn't work either.

{ Error: Command failed: npm install async npm ERR! code EROFS npm ERR! syscall mkdir npm ERR! path /home/sbx_user1051 npm ERR! errno -30 npm ERR! rofs EROFS: read-only file system, mkdir '/home/sbx_userXXXX' npm ERR! rofs Often virtualized file systems, or other file systems npm ERR! rofs that don't support symlinks, give this error.

1
Why don't you just include async in your deployment package? Whats the reason for installing it on the Lambda function? - Sam Rastovich

1 Answers

2
votes

You cannot run npm install inside lambda, you need to upload your modules using zip file

A deployment package is a ZIP archive that contains your function code and dependencies. You need to create a deployment package if you use the Lambda API to manage functions, or if you need to include libraries and dependencies other than the AWS SDK. You can upload the package directly to Lambda, or you can use an Amazon S3 bucket, and then upload it to Lambda. If the deployment package is larger than 50 MB, you must use Amazon S3.

https://docs.aws.amazon.com/lambda/latest/dg/nodejs-create-deployment-pkg.html