@@ -3198,23 +3198,29 @@ Asynchronously creates a directory.
3198
3198
The callback is given a possible exception and, if `recursive` is `true`, the
3199
3199
first directory path created, `(err[, path])`.
3200
3200
`path` can still be `undefined` when `recursive` is `true`, if no directory was
3201
- created.
3201
+ created,for instance if the directory was previously created or other issues .
3202
3202
3203
3203
The optional `options` argument can be an integer specifying `mode` (permission
3204
3204
and sticky bits), or an object with a `mode` property and a `recursive`
3205
3205
property indicating whether parent directories should be created. Calling
3206
3206
`fs.mkdir()` when `path` is a directory that exists results in an error only
3207
- when `recursive` is false.
3207
+ when `recursive` is false.That is, if we don't add `recursive` as true and
3208
+ the file was previously created,we get an EEXIST (error Exist) message telling
3209
+ us path already exists.
3208
3210
3209
3211
```mjs
3210
3212
import { mkdir } from 'node:fs';
3211
3213
3212
- // Creates /tmp/a/apple, regardless of whether `/tmp` and /tmp/a exist.
3213
- mkdir('/tmp/a/apple', { recursive: true }, (err) => {
3214
+ //Note the relative path to `tmp` below ,otherwise path won't be created in our project.
3215
+
3216
+ mkdir('./tmp/a/apple', { recursive: true }, (err) => {
3214
3217
if (err) throw err;
3215
3218
});
3216
3219
```
3217
3220
3221
+ without `recursive` being set as true it the code above,output shows an error
3222
+
3223
+
3218
3224
On Windows, using `fs.mkdir()` on the root directory even with recursion will
3219
3225
result in an error:
3220
3226
0 commit comments