Hi Guys, I’m trying to write on /tmp/file.txt
I don’t know the reason why, it keeps giving me an EROFS: read-only file system Error
I’m trying to write through a function, This the code snippet:
router.post('/data',(req,res) =>{
const content = req.body
if(content != null){
fs.writeFileSync("./tmp/file.txt",content,{encoding:'utf8',flag:'w'})
res.send("Data Updated!")
}else{
res.sendStatus(403);
}
});
Context for others:
The problem is, you’re using ./tmp
which is incorrect. The correct version is: /tmp
.
2 Likes