To use the mkdirs
function from the fs-extra
library in TypeScript, you first need to ensure that the library is installed as a dependency in your package.json
file:
28 chars2 lines
Once you have installed fs-extra
, you can import the library and use the mkdirs
function like this:
index.ts206 chars9 lines
The mkdirs
function can create directories recursively, meaning it will create all the parent directories if they do not already exist.
The example above shows how to use the synchronous version of mkdirs
. However, fs-extra
also provides an asynchronous version of the function (mkdirs
), as well as a Promise-wrapped version of both (mkdirs
and mkdirsPromise
). You can use them like this:
index.ts280 chars12 lines
With these examples, you should be able to use fs-extra
to create directories in a TypeScript project.
gistlibby LogSnag