Search code examples
node.jsdeploymentserverless

Node.js error: EROFS - read-only file system, mkdir


I'm running a Node.js application on cyclic.sh and I'm getting the following error when I try to deploy my code:

Exited with code: 226
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_user1051'
npm ERR! rofs Often virtualized file systems, or other file systems that don't support symlinks, give this error.

I'm not sure what's causing this error and how I can fix it. I've looked online and I've found that this error typically occurs when a file system is read-only or doesn't support symlinks.

This doc page suggests using the Cyclic S3fs drop-in replacement for Node.js fs to access an AWS S3 bucket for file storage in place of the local file system.

However, the hosting platform I'm using doesn't give me access to the terminal, so I can't execute any commands or make any changes directly.

Can anyone provide guidance on how I can resolve this issue? Are there any alternative solutions that I can try?

Thank you in advance for your help!


Solution

  • As the error sugests you are trying to write on a read-only filesystem. When Lambda do run they have only read+write access to /tmp/ directory aka Ephemeral Storage.

    As you pointed out from the documentation link you have the following section:

    If you are hitting the EROFS error in processing files, one solution is to write to a file that is located in a /tmp directory. However, do not use /tmp for perminant storage, as is it wiped frequently.

    So provide here what you're doing exactly or check that and try to understand where you are trying to write something to the file-system of the user sbx_user1051