Next.js Discord

Discord Forum

EROFS: read-only file system, mkdir '/var/task/public'

Unanswered
Longtail tuna posted this in #help-forum
Open in Discord
Longtail tunaOP
Error: EROFS: read-only file system, mkdir '/var/task/public'
at Object.mkdirSync (node:fs:1396:3)
at sync (/var/task/node_modules/mkdirp/index.js:74:13)
at Function.sync (/var/task/node_modules/mkdirp/index.js:80:24)
at new DiskStorage (/var/task/node_modules/multer/storage/disk.js:21:12)
at module.exports [as diskStorage] (/var/task/node_modules/multer/storage/disk.js:65:10)
at 2313 (/var/task/.next/server/chunks/2313.js:29:63)
at webpack_require (/var/task/.next/server/webpack-api-runtime.js:25:42)
at 2599 (/var/task/.next/server/pages/api/mentor.js:38:87)
at webpack_require (/var/task/.next/server/webpack-api-runtime.js:25:42)
at webpack_exec (/var/task/.next/server/pages/api/mentor.js:110:39) {
errno: -30,
syscall: 'mkdir',
code: 'EROFS',
path: '/var/task/public'
}
RequestId: de453cc8-d0b7-440e-b3e4-e044b1410089 Error: Runtime exited with error: exit status 1
Runtime.ExitError

How to fix the above error? As I'm creating and completing next.js app and deploy that to vercel and vercel log give me the above error. Please help to fix the above error.

12 Replies

Longtail tunaOP
What if I do this in cPanel?
Vercel doesn’t have cPanel
@joulev Vercel doesn’t have cPanel
Longtail tunaOP
Ok, I have cPanel that I get from NameCheap domain-hosting.
Then I don’t know, I don’t host nextjs projects with it
@Longtail tuna Ok, I have cPanel that I get from NameCheap domain-hosting.
Longtail tunaOP
Ok, then give me some correct guidelines to solve for vercel???
* I'm using Pages > API directory as RestAPI
* I'm implementing .env & server.js properly
* But I'm unable to create Node.JS application in cPanel
I need help ASAP, if anyone know Please, inbox me or comment here immediately.
I'm using multer for photo upload that store in Public > Uploads
After completing deployment API won't load or display/fetch data
When check on vercel gives me the following error:
Error: EROFS: read-only file system, mkdir '/var/task/public'
at Object.mkdirSync (node:fs:1396:3)
at sync (/var/task/node_modules/mkdirp/index.js:74:13)
at Function.sync (/var/task/node_modules/mkdirp/index.js:80:24)
at new DiskStorage (/var/task/node_modules/multer/storage/disk.js:21:12)
at module.exports [as diskStorage] (/var/task/node_modules/multer/storage/disk.js:65:10)
at 2313 (/var/task/.next/server/chunks/2313.js:29:63)
at webpack_require (/var/task/.next/server/webpack-api-runtime.js:25:42)
at 2599 (/var/task/.next/server/pages/api/mentor.js:38:87)
at webpack_require (/var/task/.next/server/webpack-api-runtime.js:25:42)
at webpack_exec (/var/task/.next/server/pages/api/mentor.js:110:39) {
errno: -30,
syscall: 'mkdir',
code: 'EROFS',
path: '/var/task/public'
}
RequestId: de453cc8-d0b7-440e-b3e4-e044b1410089 Error: Runtime exited with error: exit status 1
Runtime.ExitError
@Longtail tuna I'm using multer for photo upload that store in Public > Uploads
yes and this won't work; you cannot upload to public because the fs is read-only. you have to upload to aws s3 or cloudflare r2 or google cloud storage or a similar storage solution