Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including fs-writefile-promise with all npm packages installed. Try it out:

var fsWritefilePromise = require("fs-writefile-promise")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

fs-writefile-promise v3.0.2

Promise version of fs.writefile

fs.writeFile Promise

License version Build Status

Promise version of fs.writeFile:
Asynchronously writes data to a file, replacing the file if it already exists.


npm install fs-writefile-promise


### write(filename, data [, options])
  • filename: String
  • data String or Buffer
  • options: Object

Return: Object (Promise)

When it finishes, it will be fulfilled with the file name that was written to.

When it fails, it will be rejected with an error as its first argument.

write('/tmp/foo', 'bar')
  .then(filename => console.log(filename)) //=> '/tmp/foo'
  .catch(err => console.error(err))


The option object will be directly passed to fs.writeFile.

Author: Ahmad Nassri • Github: @ahmadnassri • Twitter: @AhmadNassri

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free