Almost the same as {\ttfamily write\+File} (i.\+e. it \href{http://pages.citebite.com/v2o5n8l2f5reb}{\texttt{ overwrites}}), except that if the parent directory does not exist, it\textquotesingle{}s created. {\ttfamily file} must be a file path (a buffer or a file descriptor is not allowed). {\ttfamily options} are what you\textquotesingle{}d pass to \href{https://nodejs.org/api/fs.html\#fs_fs_writefile_file_data_options_callback}{\texttt{ {\ttfamily fs.\+write\+File()}}}.


\begin{DoxyItemize}
\item {\ttfamily file} {\ttfamily $<$String$>$}
\item {\ttfamily data} {\ttfamily $<$String$>$ $\vert$ $<$Buffer$>$ $\vert$ $<$Uint8\+Array$>$}
\item {\ttfamily options} {\ttfamily $<$Object$>$ $\vert$ $<$String$>$}
\item {\ttfamily callback} {\ttfamily $<$Function$>$}
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_fs_extra_docs_outputFile_autotoc_md11024}{}\doxysection{Example\+:}\label{md_sfcode_node_modules_fs_extra_docs_outputFile_autotoc_md11024}

\begin{DoxyCode}{0}
\DoxyCodeLine{const fs = require('fs-\/extra')}
\DoxyCodeLine{}
\DoxyCodeLine{const file = '/tmp/this/path/does/not/exist/file.txt'}
\DoxyCodeLine{fs.outputFile(file, 'hello!', err => \{}
\DoxyCodeLine{  console.log(err) // => null}
\DoxyCodeLine{}
\DoxyCodeLine{  fs.readFile(file, 'utf8', (err, data) => \{}
\DoxyCodeLine{    if (err) return console.error(err)}
\DoxyCodeLine{    console.log(data) // => hello!}
\DoxyCodeLine{  \})}
\DoxyCodeLine{\})}
\DoxyCodeLine{}
\DoxyCodeLine{// With Promises:}
\DoxyCodeLine{fs.outputFile(file, 'hello!')}
\DoxyCodeLine{.then(() => fs.readFile(file, 'utf8'))}
\DoxyCodeLine{.then(data => \{}
\DoxyCodeLine{  console.log(data) // => hello!}
\DoxyCodeLine{\})}
\DoxyCodeLine{.catch(err => \{}
\DoxyCodeLine{  console.error(err)}
\DoxyCodeLine{\}) }

\end{DoxyCode}
 