In my website I need to create a folder and save some file in it, my code works as long I’m running it in local, but once I’ve doplyed it on render I’m getting this error
Error: ENOENT: no such file or directory, mkdir '/opt/render/desktop/data/filename
[...]
Apr 24 07:37:41 PM syscall: 'mkdir',
Apr 24 07:37:41 PM code: 'ENOENT',
Apr 24 07:37:41 PM path: '/opt/render/desktop/data/filename
This is the code I’m using to create the folder:
const fs = require("fs");
createFolder = (folderName) => {
var dir = require("path").join(
require("os").homedir(),
`desktop/data/${filename}`
);
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
};
I think the problem may be the path /opt/render/desktop/data/filename
.
How can I solve it?