Error: EROFS: read-only file system, '/var/task/tmp/tmp...'
You are here because you probably just finished a file upload feature that runs well locally but on deploying it to cyclic.sh, you encountered the error above.
Don't fret, there are 2 key things to know about this error:
- You can only write to a
tmp
folder which must be in the root folder of your project directory. - Cyclic.sh tries to navigate the
tmp
folder relative to the current working directory which is not the root folder of your project. Hence, it appends/var/task/
to thetmp
directory itself.
The simple solution is to set the value of one of the parameters in your express-fileupload package as shown below. I would assume you have installed both express-fileupload
and express
, if not, run the following command:
npm install express-fileupload express
// The Solution
const express = require('express');
const fileupload = require('express-fileupload');
app.use(fileupload({
useTempFiles: true,
tempFileDir: "/tmp",
}))
It is important that you set the value of the tempFileDir
property to be \tmp
. This way, cyclic.sh is able to navigate the tmp
folder relative to the root directory. You can read more on express-fileupload.
I hope this helped. Thanks for reading.
Top comments (4)
i do the same code but the problem still exist
can the photo be obtained?
Yes, I was.
I used it alongside cloudinary which saved my data in cloud and I could just fetch from there.
The tmp folder just served as an intermediary folder between my deployed app and where I finally want it(cloudinary)
I had the same problem. In my problem, I was able to write data to temp folder but still can't get data from that folder?