Node.js Overwriting a file

I know it is a simple question, but haven't been able to find anything useful on this one.

How do you use fs.createWriteStream(dst) to overwrite a file? (note that the app is hosted on heroku)

I tried {flags: 'w'} or {flags: 'r+'} even {flags: 'wb'}. None of these worked, I keep getting Error: File uploads/1.txt exists.

From the docs:

Modifying a file rather than replacing it may require a flags mode of r+ rather than the default mode w.

So {flags: 'w'} should work. This sounds like a permissions issue?

Are you able to do an fs.unlink() on that file? This should test the permissions on that file if you don't have access to the computer directly.