Error when trying to create a folder from deployed website

In the code I’ve succesfully deployed I’m creating a new folder like this:

const fs = require("fs");

createFolder = (folderName) => {
  var dir = require("path").join(
    require("os").homedir(),
    `desktop/data/${filename}`
  );
  if (!fs.existsSync(dir)) {
    fs.mkdirSync(dir);
  }
};

It worked just fine when I run it in local, but now it gives e back 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

What should I do to fix it and be able to create a folder again?

Hey,

You probably want to write files in ~/project/src or in a Disk, not at this path.

Regards.
Jérémy, Render Support

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.