• Home
  • Raw
  • Download

Lines Matching +full:node +full:- +full:version

3 <!--introduced_in=v0.10.0-->
5 > Stability: 2 - Stable
7 <!--name=fs-->
9 <!-- source_link=lib/fs.js -->
11 The `node:fs` module enables interacting with the file system in a
14 To use the promise-based APIs:
17 import * as fs from 'node:fs/promises';
21 const fs = require('node:fs/promises');
27 import * as fs from 'node:fs';
31 const fs = require('node:fs');
34 All file system operations have synchronous, callback, and promise-based
39 Promise-based operations return a promise that is fulfilled when the
43 import { unlink } from 'node:fs/promises';
54 const { unlink } = require('node:fs/promises');
75 import { unlink } from 'node:fs';
84 const { unlink } = require('node:fs');
92 The callback-based versions of the `node:fs` module APIs are preferable over
98 The synchronous APIs block the Node.js event loop and further JavaScript
103 import { unlinkSync } from 'node:fs';
114 const { unlinkSync } = require('node:fs');
126 <!-- YAML
129 - version: v14.0.0
130 pr-url: https://github.com/nodejs/node/pull/31553
132 - version:
133 - v11.14.0
134 - v10.17.0
135 pr-url: https://github.com/nodejs/node/pull/26581
137 - version: v10.1.0
138 pr-url: https://github.com/nodejs/node/pull/20504
140 -->
145 The promise APIs use the underlying Node.js threadpool to perform file
152 <!-- YAML
154 -->
167 close {FileHandle}s. Node.js may change this behavior in the future.
171 <!-- YAML
173 -->
180 <!-- YAML
183 - version:
184 - v15.14.0
185 - v14.18.0
186 pr-url: https://github.com/nodejs/node/pull/37490
188 - version: v14.0.0
189 pr-url: https://github.com/nodejs/node/pull/31030
192 -->
207 <!-- YAML
209 -->
218 <!-- YAML
220 -->
230 <!-- YAML
232 -->
240 import { open } from 'node:fs/promises';
252 <!-- YAML
254 -->
285 import { open } from 'node:fs/promises';
292 // Artificially marking end-of-stream, as if the underlying resource had
293 // indicated end-of-file by itself, allows the stream to close.
311 import { open } from 'node:fs/promises';
319 <!-- YAML
321 -->
347 <!-- YAML
349 -->
361 <!-- YAML
363 -->
369 <!-- YAML
371 -->
388 If the file is not modified concurrently, the end-of-file is reached when the
393 <!-- YAML
395 - v13.11.0
396 - v12.17.0
397 -->
405 `buffer.byteLength - offset`
417 If the file is not modified concurrently, the end-of-file is reached when the
422 <!-- YAML
424 -->
432 `buffer.byteLength - offset`
444 If the file is not modified concurrently, the end-of-file is reached when the
449 <!-- YAML
452 - version: v18.17.0
453 pr-url: https://github.com/nodejs/node/pull/46933
455 -->
457 > Stability: 1 - Experimental
473 } from 'node:fs/promises';
486 } = require('node:fs/promises');
504 <!-- YAML
506 -->
510 * `signal` {AbortSignal} allows aborting an in-progress readFile
528 <!-- YAML
530 -->
545 import { open } from 'node:fs/promises';
555 const { open } = require('node:fs/promises');
568 <!-- YAML
570 - v13.13.0
571 - v12.17.0
572 -->
587 <!-- YAML
590 - version: v10.5.0
591 pr-url: https://github.com/nodejs/node/pull/20220
594 -->
603 <!-- YAML
605 -->
615 <!-- YAML
617 -->
630 import { open } from 'node:fs/promises';
648 <!-- YAML
650 -->
661 <!-- YAML
664 - version: v14.0.0
665 pr-url: https://github.com/nodejs/node/pull/31030
668 -->
674 `buffer.byteLength - offset`
699 <!-- YAML
701 -->
706 * `length` {integer} **Default:** `buffer.byteLength - offset`
712 Similar to the above `filehandle.write` function, this version takes an
718 <!-- YAML
721 - version: v14.0.0
722 pr-url: https://github.com/nodejs/node/pull/31030
725 -->
753 <!-- YAML
756 - version:
757 - v15.14.0
758 - v14.18.0
759 pr-url: https://github.com/nodejs/node/pull/37490
761 - version: v14.0.0
762 pr-url: https://github.com/nodejs/node/pull/31030
765 -->
791 <!-- YAML
793 -->
818 <!-- YAML
820 -->
822 > Stability: 1 - Experimental
828 <!-- YAML
830 -->
850 import { access, constants } from 'node:fs/promises';
868 <!-- YAML
870 -->
893 <!-- YAML
895 -->
905 <!-- YAML
907 -->
918 <!-- YAML
921 - version: v14.0.0
922 pr-url: https://github.com/nodejs/node/pull/27044
925 -->
937 a copy-on-write reflink. If the platform does not support copy-on-write,
940 create a copy-on-write reflink. If the platform does not support
941 copy-on-write, then the operation will fail.
952 import { copyFile, constants } from 'node:fs/promises';
972 <!-- YAML
975 - version: v18.17.0
976 pr-url: https://github.com/nodejs/node/pull/47084
979 - version: v17.6.0
980 pr-url: https://github.com/nodejs/node/pull/41819
983 -->
985 > Stability: 1 - Experimental
1021 <!-- YAML
1023 -->
1035 <!-- YAML
1038 - version: v10.6.0
1039 pr-url: https://github.com/nodejs/node/pull/21498
1041 -->
1052 <!-- YAML
1054 - v14.5.0
1055 - v12.19.0
1056 -->
1070 <!-- YAML
1072 -->
1083 <!-- YAML
1086 - version: v10.5.0
1087 pr-url: https://github.com/nodejs/node/pull/20220
1090 -->
1100 in which case the link itself is stat-ed, not the file that it refers to.
1105 <!-- YAML
1107 -->
1125 import { mkdir } from 'node:fs/promises';
1138 const { mkdir } = require('node:fs/promises');
1139 const { join } = require('node:path');
1154 <!-- YAML
1157 - version: v18.19.0
1158 pr-url: https://github.com/nodejs/node/pull/48828
1160 - version:
1161 - v16.5.0
1162 - v14.18.0
1163 pr-url: https://github.com/nodejs/node/pull/39028
1165 -->
1183 import { mkdtemp } from 'node:fs/promises';
1184 import { join } from 'node:path';
1185 import { tmpdir } from 'node:os';
1188 await mkdtemp(join(tmpdir(), 'foo-'));
1197 `prefix` must end with a trailing platform-specific path separator
1198 (`require('node:path').sep`).
1202 <!-- YAML
1205 - version: v11.1.0
1206 pr-url: https://github.com/nodejs/node/pull/23767
1208 -->
1223 a colon, Node.js will open a file system stream, as described by
1224 [this MSDN page][MSDN-Using-Streams].
1228 <!-- YAML
1231 - version: v18.17.0
1232 pr-url: https://github.com/nodejs/node/pull/41439
1234 - version:
1235 - v13.1.0
1236 - v12.16.0
1237 pr-url: https://github.com/nodejs/node/pull/30114
1239 -->
1263 import { opendir } from 'node:fs/promises';
1279 <!-- YAML
1282 - version: v18.17.0
1283 pr-url: https://github.com/nodejs/node/pull/41439
1285 - version: v10.11.0
1286 pr-url: https://github.com/nodejs/node/pull/22020
1288 -->
1309 import { readdir } from 'node:fs/promises';
1322 <!-- YAML
1325 - version:
1326 - v15.2.0
1327 - v14.17.0
1328 pr-url: https://github.com/nodejs/node/pull/35911
1331 -->
1337 * `signal` {AbortSignal} allows aborting an in-progress readFile
1348 platform-specific. On macOS, Linux, and Windows, the promise will be rejected
1356 import { readFile } from 'node:fs/promises';
1367 const { readFile } = require('node:fs/promises');
1368 const { resolve } = require('node:path');
1385 import { readFile } from 'node:fs/promises';
1397 // When a request is aborted - err is an AbortError
1409 <!-- YAML
1411 -->
1429 <!-- YAML
1431 -->
1448 On Linux, when Node.js is linked against musl libc, the procfs file system must
1454 <!-- YAML
1456 -->
1466 <!-- YAML
1469 - version: v16.0.0
1470 pr-url: https://github.com/nodejs/node/pull/37216
1474 - version: v16.0.0
1475 pr-url: https://github.com/nodejs/node/pull/37216
1479 - version: v16.0.0
1480 pr-url: https://github.com/nodejs/node/pull/37302
1483 - version: v14.14.0
1484 pr-url: https://github.com/nodejs/node/pull/35579
1486 - version:
1487 - v13.3.0
1488 - v12.16.0
1489 pr-url: https://github.com/nodejs/node/pull/30644
1495 - version: v12.10.0
1496 pr-url: https://github.com/nodejs/node/pull/29168
1499 -->
1504 `EPERM` error is encountered, Node.js retries the operation with a linear
1522 To get a behavior similar to the `rm -rf` Unix command, use
1527 <!-- YAML
1529 -->
1536 `EPERM` error is encountered, Node.js will retry the operation with a linear
1551 <!-- YAML
1554 - version: v10.5.0
1555 pr-url: https://github.com/nodejs/node/pull/20220
1558 -->
1569 <!-- YAML
1571 -->
1582 <!-- YAML
1584 -->
1601 <!-- YAML
1603 -->
1614 <!-- YAML
1616 -->
1628 <!-- YAML
1630 -->
1644 `-Infinity`, an `Error` will be thrown.
1648 <!-- YAML
1650 - v15.9.0
1651 - v14.18.0
1652 -->
1674 const { watch } = require('node:fs/promises');
1700 <!-- YAML
1703 - version:
1704 - v15.14.0
1705 - v14.18.0
1706 pr-url: https://github.com/nodejs/node/pull/37490
1708 - version:
1709 - v15.2.0
1710 - v14.17.0
1711 pr-url: https://github.com/nodejs/node/pull/35993
1714 - version: v14.0.0
1715 pr-url: https://github.com/nodejs/node/pull/31030
1718 -->
1726 * `signal` {AbortSignal} allows aborting an in-progress writeFile
1744 Similarly to `fsPromises.readFile` - `fsPromises.writeFile` is a convenience
1754 import { writeFile } from 'node:fs/promises';
1755 import { Buffer } from 'node:buffer';
1760 const data = new Uint8Array(Buffer.from('Hello Node.js'));
1768 // When a request is aborted - err is an AbortError
1778 <!-- YAML
1780 - v18.4.0
1781 - v16.17.0
1782 -->
1795 The callback APIs use the underlying Node.js threadpool to perform file
1802 <!-- YAML
1805 - version: v18.0.0
1806 pr-url: https://github.com/nodejs/node/pull/41678
1810 - version: v7.6.0
1811 pr-url: https://github.com/nodejs/node/pull/10739
1814 - version: v6.3.0
1815 pr-url: https://github.com/nodejs/node/pull/6534
1818 Thus for Node.js `< v6.3.0` use `fs`
1822 -->
1843 import { access, constants } from 'node:fs';
1877 import { access, open, close } from 'node:fs';
1902 import { open, close } from 'node:fs';
1927 import { access, open, close } from 'node:fs';
1955 import { open, close } from 'node:fs';
1985 On Windows, access-control policies (ACLs) on a directory may limit access to
1992 <!-- YAML
1995 - version: v18.0.0
1996 pr-url: https://github.com/nodejs/node/pull/41678
2000 - version: v10.0.0
2001 pr-url: https://github.com/nodejs/node/pull/12562
2004 - version: v7.0.0
2005 pr-url: https://github.com/nodejs/node/pull/7897
2008 - version: v7.0.0
2009 pr-url: https://github.com/nodejs/node/pull/7831
2011 - version: v5.0.0
2012 pr-url: https://github.com/nodejs/node/pull/3163
2014 -->
2032 import { appendFile } from 'node:fs';
2043 import { appendFile } from 'node:fs';
2053 import { open, close, appendFile } from 'node:fs';
2078 <!-- YAML
2081 - version: v18.0.0
2082 pr-url: https://github.com/nodejs/node/pull/41678
2086 - version: v10.0.0
2087 pr-url: https://github.com/nodejs/node/pull/12562
2090 - version: v7.6.0
2091 pr-url: https://github.com/nodejs/node/pull/10739
2094 - version: v7.0.0
2095 pr-url: https://github.com/nodejs/node/pull/7897
2098 -->
2111 import { chmod } from 'node:fs';
2126 | ---------------------- | ------- | ------------------------ |
2138 octal digits (e.g. `765`). The left-most digit (`7` in the example), specifies
2140 specifies permissions for the group. The right-most digit (`5` in the example),
2144 | ------ | ------------------------ |
2161 `0o777` may result in platform-specific behaviors that are not supported to work
2171 <!-- YAML
2174 - version: v18.0.0
2175 pr-url: https://github.com/nodejs/node/pull/41678
2179 - version: v10.0.0
2180 pr-url: https://github.com/nodejs/node/pull/12562
2183 - version: v7.6.0
2184 pr-url: https://github.com/nodejs/node/pull/10739
2187 - version: v7.0.0
2188 pr-url: https://github.com/nodejs/node/pull/7897
2191 -->
2206 <!-- YAML
2209 - version: v18.0.0
2210 pr-url: https://github.com/nodejs/node/pull/41678
2214 - version:
2215 - v15.9.0
2216 - v14.17.0
2217 pr-url: https://github.com/nodejs/node/pull/37174
2219 - version: v10.0.0
2220 pr-url: https://github.com/nodejs/node/pull/12562
2223 - version: v7.0.0
2224 pr-url: https://github.com/nodejs/node/pull/7897
2227 -->
2243 <!-- YAML
2246 - version: v18.0.0
2247 pr-url: https://github.com/nodejs/node/pull/41678
2251 - version: v14.0.0
2252 pr-url: https://github.com/nodejs/node/pull/27044
2255 -->
2264 callback function. Node.js makes no guarantees about the atomicity of the copy
2266 writing, Node.js will attempt to remove the destination.
2276 copy-on-write reflink. If the platform does not support copy-on-write, then a
2279 create a copy-on-write reflink. If the platform does not support
2280 copy-on-write, then the operation will fail.
2283 import { copyFile, constants } from 'node:fs';
2299 <!-- YAML
2302 - version: v18.17.0
2303 pr-url: https://github.com/nodejs/node/pull/47084
2306 - version: v18.0.0
2307 pr-url: https://github.com/nodejs/node/pull/41678
2311 - version: v17.6.0
2312 pr-url: https://github.com/nodejs/node/pull/41819
2315 -->
2317 > Stability: 1 - Experimental
2353 <!-- YAML
2356 - version: v16.10.0
2357 pr-url: https://github.com/nodejs/node/pull/40013
2359 - version: v16.10.0
2360 pr-url: https://github.com/nodejs/node/pull/40013
2362 - version: v15.5.0
2363 pr-url: https://github.com/nodejs/node/pull/36431
2365 - version:
2366 - v15.4.0
2367 pr-url: https://github.com/nodejs/node/pull/35922
2369 - version: v14.0.0
2370 pr-url: https://github.com/nodejs/node/pull/31408
2372 - version:
2373 - v13.6.0
2374 - v12.17.0
2375 pr-url: https://github.com/nodejs/node/pull/29083
2378 - version: v12.10.0
2379 pr-url: https://github.com/nodejs/node/pull/29212
2381 - version: v11.0.0
2382 pr-url: https://github.com/nodejs/node/pull/19898
2386 - version: v7.6.0
2387 pr-url: https://github.com/nodejs/node/pull/10739
2390 - version: v7.0.0
2391 pr-url: https://github.com/nodejs/node/pull/7831
2393 - version: v2.3.0
2394 pr-url: https://github.com/nodejs/node/pull/1845
2396 -->
2427 emitted. `fd` should be blocking; non-blocking `fd`s should be passed to
2445 import { createReadStream } from 'node:fs';
2451 // Artificially marking end-of-stream, as if the underlying resource had
2452 // indicated end-of-file by itself, allows the stream to close.
2473 import { createReadStream } from 'node:fs';
2482 <!-- YAML
2485 - version: v16.10.0
2486 pr-url: https://github.com/nodejs/node/pull/40013
2488 - version: v16.10.0
2489 pr-url: https://github.com/nodejs/node/pull/40013
2491 - version: v15.5.0
2492 pr-url: https://github.com/nodejs/node/pull/36431
2494 - version:
2495 - v15.4.0
2496 pr-url: https://github.com/nodejs/node/pull/35922
2498 - version: v14.0.0
2499 pr-url: https://github.com/nodejs/node/pull/31408
2501 - version:
2502 - v13.6.0
2503 - v12.17.0
2504 pr-url: https://github.com/nodejs/node/pull/29083
2507 - version: v12.10.0
2508 pr-url: https://github.com/nodejs/node/pull/29212
2510 - version: v7.6.0
2511 pr-url: https://github.com/nodejs/node/pull/10739
2514 - version: v7.0.0
2515 pr-url: https://github.com/nodejs/node/pull/7831
2517 - version: v5.5.0
2518 pr-url: https://github.com/nodejs/node/pull/3679
2520 - version: v2.3.0
2521 pr-url: https://github.com/nodejs/node/pull/1845
2523 -->
2564 `'open'` event will be emitted. `fd` should be blocking; non-blocking `fd`s
2571 <!-- YAML
2575 - version: v18.0.0
2576 pr-url: https://github.com/nodejs/node/pull/41678
2580 - version: v7.6.0
2581 pr-url: https://github.com/nodejs/node/pull/10739
2584 -->
2586 > Stability: 0 - Deprecated: Use [`fs.stat()`][] or [`fs.access()`][] instead.
2596 import { exists } from 'node:fs';
2603 **The parameters for this callback are not consistent with other Node.js
2604 callbacks.** Normally, the first parameter to a Node.js callback is an `err`
2618 import { exists, open, close } from 'node:fs';
2642 import { open, close } from 'node:fs';
2666 import { open, close, exists } from 'node:fs';
2690 import { open, close } from 'node:fs';
2722 <!-- YAML
2725 - version: v18.0.0
2726 pr-url: https://github.com/nodejs/node/pull/41678
2730 - version: v10.0.0
2731 pr-url: https://github.com/nodejs/node/pull/12562
2734 - version: v7.0.0
2735 pr-url: https://github.com/nodejs/node/pull/7897
2738 -->
2752 <!-- YAML
2755 - version: v18.0.0
2756 pr-url: https://github.com/nodejs/node/pull/41678
2760 - version: v10.0.0
2761 pr-url: https://github.com/nodejs/node/pull/12562
2764 - version: v7.0.0
2765 pr-url: https://github.com/nodejs/node/pull/7897
2768 -->
2783 <!-- YAML
2786 - version: v18.0.0
2787 pr-url: https://github.com/nodejs/node/pull/41678
2791 - version: v10.0.0
2792 pr-url: https://github.com/nodejs/node/pull/12562
2795 - version: v7.0.0
2796 pr-url: https://github.com/nodejs/node/pull/7897
2799 -->
2812 <!-- YAML
2815 - version: v18.0.0
2816 pr-url: https://github.com/nodejs/node/pull/41678
2820 - version: v10.5.0
2821 pr-url: https://github.com/nodejs/node/pull/20220
2824 - version: v10.0.0
2825 pr-url: https://github.com/nodejs/node/pull/12562
2828 - version: v7.0.0
2829 pr-url: https://github.com/nodejs/node/pull/7897
2832 -->
2848 <!-- YAML
2851 - version: v18.0.0
2852 pr-url: https://github.com/nodejs/node/pull/41678
2856 - version: v10.0.0
2857 pr-url: https://github.com/nodejs/node/pull/12562
2860 - version: v7.0.0
2861 pr-url: https://github.com/nodejs/node/pull/7897
2864 -->
2877 <!-- YAML
2880 - version: v18.0.0
2881 pr-url: https://github.com/nodejs/node/pull/41678
2885 - version: v10.0.0
2886 pr-url: https://github.com/nodejs/node/pull/12562
2889 - version: v7.0.0
2890 pr-url: https://github.com/nodejs/node/pull/7897
2893 -->
2912 import { open, close, ftruncate } from 'node:fs';
2942 <!-- YAML
2945 - version: v18.0.0
2946 pr-url: https://github.com/nodejs/node/pull/41678
2950 - version: v10.0.0
2951 pr-url: https://github.com/nodejs/node/pull/12562
2954 - version: v7.0.0
2955 pr-url: https://github.com/nodejs/node/pull/7897
2958 - version: v4.1.0
2959 pr-url: https://github.com/nodejs/node/pull/2387
2962 -->
2975 <!-- YAML
2978 - version: v18.0.0
2979 pr-url: https://github.com/nodejs/node/pull/41678
2983 - version: v16.0.0
2984 pr-url: https://github.com/nodejs/node/pull/37460
2987 - version: v10.0.0
2988 pr-url: https://github.com/nodejs/node/pull/12562
2991 - version: v7.0.0
2992 pr-url: https://github.com/nodejs/node/pull/7897
2995 -->
3011 <!-- YAML
3013 - version: v18.0.0
3014 pr-url: https://github.com/nodejs/node/pull/41678
3018 - version: v10.6.0
3019 pr-url: https://github.com/nodejs/node/pull/21498
3021 - version: v10.0.0
3022 pr-url: https://github.com/nodejs/node/pull/12562
3025 - version: v7.0.0
3026 pr-url: https://github.com/nodejs/node/pull/7897
3029 - version: v0.4.7
3030 description: Documentation-only deprecation.
3031 -->
3046 <!-- YAML
3048 - v14.5.0
3049 - v12.19.0
3051 - version: v18.0.0
3052 pr-url: https://github.com/nodejs/node/pull/41678
3056 -->
3074 <!-- YAML
3077 - version: v18.0.0
3078 pr-url: https://github.com/nodejs/node/pull/41678
3082 - version: v10.0.0
3083 pr-url: https://github.com/nodejs/node/pull/12562
3086 - version: v7.6.0
3087 pr-url: https://github.com/nodejs/node/pull/10739
3091 - version: v7.0.0
3092 pr-url: https://github.com/nodejs/node/pull/7897
3095 -->
3108 <!-- YAML
3111 - version: v18.0.0
3112 pr-url: https://github.com/nodejs/node/pull/41678
3116 - version: v10.5.0
3117 pr-url: https://github.com/nodejs/node/pull/20220
3120 - version: v10.0.0
3121 pr-url: https://github.com/nodejs/node/pull/12562
3124 - version: v7.6.0
3125 pr-url: https://github.com/nodejs/node/pull/10739
3128 - version: v7.0.0
3129 pr-url: https://github.com/nodejs/node/pull/7897
3132 -->
3145 link, then the link itself is stat-ed, not the file that it refers to.
3151 <!-- YAML
3154 - version: v18.0.0
3155 pr-url: https://github.com/nodejs/node/pull/41678
3159 - version:
3160 - v13.11.0
3161 - v12.17.0
3162 pr-url: https://github.com/nodejs/node/pull/31530
3165 - version: v10.12.0
3166 pr-url: https://github.com/nodejs/node/pull/21875
3169 - version: v10.0.0
3170 pr-url: https://github.com/nodejs/node/pull/12562
3173 - version: v7.6.0
3174 pr-url: https://github.com/nodejs/node/pull/10739
3177 - version: v7.0.0
3178 pr-url: https://github.com/nodejs/node/pull/7897
3181 -->
3207 import { mkdir } from 'node:fs';
3219 import { mkdir } from 'node:fs';
3230 <!-- YAML
3233 - version: v18.19.0
3234 pr-url: https://github.com/nodejs/node/pull/48828
3236 - version: v18.0.0
3237 pr-url: https://github.com/nodejs/node/pull/41678
3241 - version:
3242 - v16.5.0
3243 - v14.18.0
3244 pr-url: https://github.com/nodejs/node/pull/39028
3246 - version: v10.0.0
3247 pr-url: https://github.com/nodejs/node/pull/12562
3250 - version: v7.0.0
3251 pr-url: https://github.com/nodejs/node/pull/7897
3254 - version: v6.2.1
3255 pr-url: https://github.com/nodejs/node/pull/6828
3257 -->
3281 import { mkdtemp } from 'node:fs';
3282 import { join } from 'node:path';
3283 import { tmpdir } from 'node:os';
3285 mkdtemp(join(tmpdir(), 'foo-'), (err, directory) => {
3288 // Prints: /tmp/foo-itXde2 or C:\Users\...\AppData\Local\Temp\foo-itXde2
3295 must end with a trailing platform-specific path separator
3296 (`require('node:path').sep`).
3299 import { tmpdir } from 'node:os';
3300 import { mkdtemp } from 'node:fs';
3315 import { sep } from 'node:path';
3327 <!-- YAML
3330 - version: v18.0.0
3331 pr-url: https://github.com/nodejs/node/pull/41678
3335 - version: v11.1.0
3336 pr-url: https://github.com/nodejs/node/pull/23767
3338 - version: v9.9.0
3339 pr-url: https://github.com/nodejs/node/pull/18801
3341 - version: v7.6.0
3342 pr-url: https://github.com/nodejs/node/pull/10739
3345 -->
3365 a colon, Node.js will open a file system stream, as described by
3366 [this MSDN page][MSDN-Using-Streams].
3373 <!-- YAML
3376 - version: v18.17.0
3377 pr-url: https://github.com/nodejs/node/pull/41439
3379 - version: v18.0.0
3380 pr-url: https://github.com/nodejs/node/pull/41678
3384 - version:
3385 - v13.1.0
3386 - v12.16.0
3387 pr-url: https://github.com/nodejs/node/pull/30114
3389 -->
3413 <!-- YAML
3416 - version: v18.0.0
3417 pr-url: https://github.com/nodejs/node/pull/41678
3421 - version: v10.10.0
3422 pr-url: https://github.com/nodejs/node/pull/22150
3425 - version: v7.4.0
3426 pr-url: https://github.com/nodejs/node/pull/10382
3428 - version: v6.0.0
3429 pr-url: https://github.com/nodejs/node/pull/4518
3431 -->
3439 file. If `position` is `null` or `-1 `, data will be read from the current
3451 If the file is not modified concurrently, the end-of-file is reached when the
3454 If this method is invoked as its [`util.promisify()`][]ed version, it returns
3459 <!-- YAML
3461 - v13.11.0
3462 - v12.17.0
3464 - version:
3465 - v13.11.0
3466 - v12.17.0
3467 pr-url: https://github.com/nodejs/node/pull/31402
3470 -->
3476 * `length` {integer} **Default:** `buffer.byteLength - offset`
3483 Similar to the [`fs.read()`][] function, this version takes an optional
3489 <!-- YAML
3491 -->
3498 * `length` {integer} **Default:** `buffer.byteLength - offset`
3505 Similar to the [`fs.read()`][] function, this version takes an optional
3511 <!-- YAML
3514 - version: v18.17.0
3515 pr-url: https://github.com/nodejs/node/pull/41439
3517 - version: v18.0.0
3518 pr-url: https://github.com/nodejs/node/pull/41678
3522 - version: v10.10.0
3523 pr-url: https://github.com/nodejs/node/pull/22020
3525 - version: v10.0.0
3526 pr-url: https://github.com/nodejs/node/pull/12562
3529 - version: v7.6.0
3530 pr-url: https://github.com/nodejs/node/pull/10739
3533 - version: v7.0.0
3534 pr-url: https://github.com/nodejs/node/pull/7897
3537 - version: v6.0.0
3538 pr-url: https://github.com/nodejs/node/pull/5616
3540 -->
3567 <!-- YAML
3570 - version: v18.0.0
3571 pr-url: https://github.com/nodejs/node/pull/41678
3575 - version: v16.0.0
3576 pr-url: https://github.com/nodejs/node/pull/37460
3579 - version:
3580 - v15.2.0
3581 - v14.17.0
3582 pr-url: https://github.com/nodejs/node/pull/35911
3585 - version: v10.0.0
3586 pr-url: https://github.com/nodejs/node/pull/12562
3589 - version: v7.6.0
3590 pr-url: https://github.com/nodejs/node/pull/10739
3593 - version: v7.0.0
3594 pr-url: https://github.com/nodejs/node/pull/7897
3597 - version: v5.1.0
3598 pr-url: https://github.com/nodejs/node/pull/3740
3601 - version: v5.0.0
3602 pr-url: https://github.com/nodejs/node/pull/3163
3604 -->
3610 * `signal` {AbortSignal} allows aborting an in-progress readFile
3618 import { readFile } from 'node:fs';
3634 import { readFile } from 'node:fs';
3640 [`fs.readFileSync()`][] is platform-specific. On macOS, Linux, and Windows, an
3645 import { readFile } from 'node:fs';
3662 import { readFile } from 'node:fs';
3699 for instance) and Node.js is unable to determine an actual file size, each read
3703 For applications that require as-fast-as-possible reading of file contents, it
3707 The Node.js GitHub issue [#25741][] provides more information and a detailed
3709 different Node.js versions.
3713 <!-- YAML
3716 - version: v18.0.0
3717 pr-url: https://github.com/nodejs/node/pull/41678
3721 - version: v10.0.0
3722 pr-url: https://github.com/nodejs/node/pull/12562
3725 - version: v7.6.0
3726 pr-url: https://github.com/nodejs/node/pull/10739
3729 - version: v7.0.0
3730 pr-url: https://github.com/nodejs/node/pull/7897
3733 -->
3754 <!-- YAML
3756 - v13.13.0
3757 - v12.17.0
3759 - version: v18.0.0
3760 pr-url: https://github.com/nodejs/node/pull/41678
3764 -->
3784 If this method is invoked as its [`util.promisify()`][]ed version, it returns
3789 <!-- YAML
3792 - version: v18.0.0
3793 pr-url: https://github.com/nodejs/node/pull/41678
3797 - version: v10.0.0
3798 pr-url: https://github.com/nodejs/node/pull/12562
3801 - version: v8.0.0
3802 pr-url: https://github.com/nodejs/node/pull/13028
3804 - version: v7.6.0
3805 pr-url: https://github.com/nodejs/node/pull/10739
3808 - version: v7.0.0
3809 pr-url: https://github.com/nodejs/node/pull/7897
3812 - version: v6.4.0
3813 pr-url: https://github.com/nodejs/node/pull/7899
3816 - version: v6.0.0
3817 pr-url: https://github.com/nodejs/node/pull/3594
3819 -->
3836 1. No case conversion is performed on case-insensitive file systems.
3838 2. The maximum number of symbolic links is platform-independent and generally
3856 <!-- YAML
3859 - version: v18.0.0
3860 pr-url: https://github.com/nodejs/node/pull/41678
3864 -->
3884 On Linux, when Node.js is linked against musl libc, the procfs file system must
3890 <!-- YAML
3893 - version: v18.0.0
3894 pr-url: https://github.com/nodejs/node/pull/41678
3898 - version: v10.0.0
3899 pr-url: https://github.com/nodejs/node/pull/12562
3902 - version: v7.6.0
3903 pr-url: https://github.com/nodejs/node/pull/10739
3907 - version: v7.0.0
3908 pr-url: https://github.com/nodejs/node/pull/7897
3911 -->
3927 import { rename } from 'node:fs';
3937 <!-- YAML
3940 - version: v18.0.0
3941 pr-url: https://github.com/nodejs/node/pull/41678
3945 - version: v16.0.0
3946 pr-url: https://github.com/nodejs/node/pull/37216
3950 - version: v16.0.0
3951 pr-url: https://github.com/nodejs/node/pull/37216
3955 - version: v16.0.0
3956 pr-url: https://github.com/nodejs/node/pull/37302
3959 - version: v14.14.0
3960 pr-url: https://github.com/nodejs/node/pull/35579
3962 - version:
3963 - v13.3.0
3964 - v12.16.0
3965 pr-url: https://github.com/nodejs/node/pull/30644
3971 - version: v12.10.0
3972 pr-url: https://github.com/nodejs/node/pull/29168
3975 - version: v10.0.0
3976 pr-url: https://github.com/nodejs/node/pull/12562
3979 - version: v7.6.0
3980 pr-url: https://github.com/nodejs/node/pull/10739
3983 - version: v7.0.0
3984 pr-url: https://github.com/nodejs/node/pull/7897
3987 -->
3992 `EPERM` error is encountered, Node.js retries the operation with a linear
4011 To get a behavior similar to the `rm -rf` Unix command, use [`fs.rm()`][]
4016 <!-- YAML
4019 - version:
4020 - v17.3.0
4021 - v16.14.0
4022 pr-url: https://github.com/nodejs/node/pull/41132
4025 -->
4032 `EPERM` error is encountered, Node.js will retry the operation with a linear
4050 <!-- YAML
4053 - version: v18.0.0
4054 pr-url: https://github.com/nodejs/node/pull/41678
4058 - version: v10.5.0
4059 pr-url: https://github.com/nodejs/node/pull/20220
4062 - version: v10.0.0
4063 pr-url: https://github.com/nodejs/node/pull/12562
4066 - version: v7.6.0
4067 pr-url: https://github.com/nodejs/node/pull/10739
4070 - version: v7.0.0
4071 pr-url: https://github.com/nodejs/node/pull/7897
4074 -->
4103 - txtDir
4104 -- file.txt
4105 - app.js
4111 import { stat } from 'node:fs';
4142 atime: 2019-06-22T03:37:33.072Z,
4143 mtime: 2019-06-22T03:36:54.583Z,
4144 ctime: 2019-06-22T03:37:06.624Z,
4145 birthtime: 2019-06-22T03:28:46.937Z
4163 atime: 2019-06-22T03:36:56.619Z,
4164 mtime: 2019-06-22T03:36:54.584Z,
4165 ctime: 2019-06-22T03:36:54.584Z,
4166 birthtime: 2019-06-22T03:26:47.711Z
4172 <!-- YAML
4174 -->
4192 <!-- YAML
4195 - version: v18.0.0
4196 pr-url: https://github.com/nodejs/node/pull/41678
4200 - version: v12.0.0
4201 pr-url: https://github.com/nodejs/node/pull/23724
4202 description: If the `type` argument is left undefined, Node will autodetect
4204 - version: v7.6.0
4205 pr-url: https://github.com/nodejs/node/pull/10739
4209 -->
4224 not a string, Node.js will autodetect `target` type and use `'file'` or `'dir'`.
4233 import { symlink } from 'node:fs';
4245 └── mewtwo -> ./mew
4250 <!-- YAML
4253 - version: v18.0.0
4254 pr-url: https://github.com/nodejs/node/pull/41678
4258 - version: v16.0.0
4259 pr-url: https://github.com/nodejs/node/pull/37460
4262 - version: v10.0.0
4263 pr-url: https://github.com/nodejs/node/pull/12562
4266 - version: v7.0.0
4267 pr-url: https://github.com/nodejs/node/pull/7897
4270 -->
4282 import { truncate } from 'node:fs';
4291 const { truncate } = require('node:fs');
4306 <!-- YAML
4309 - version: v18.0.0
4310 pr-url: https://github.com/nodejs/node/pull/41678
4314 - version: v10.0.0
4315 pr-url: https://github.com/nodejs/node/pull/12562
4318 - version: v7.6.0
4319 pr-url: https://github.com/nodejs/node/pull/10739
4322 - version: v7.0.0
4323 pr-url: https://github.com/nodejs/node/pull/7897
4326 -->
4336 import { unlink } from 'node:fs';
4351 <!-- YAML
4353 -->
4364 no-op, not an error.
4372 <!-- YAML
4375 - version: v18.0.0
4376 pr-url: https://github.com/nodejs/node/pull/41678
4380 - version: v10.0.0
4381 pr-url: https://github.com/nodejs/node/pull/12562
4384 - version: v8.0.0
4385 pr-url: https://github.com/nodejs/node/pull/11919
4386 description: "`NaN`, `Infinity`, and `-Infinity` are no longer valid time
4388 - version: v7.6.0
4389 pr-url: https://github.com/nodejs/node/pull/10739
4392 - version: v7.0.0
4393 pr-url: https://github.com/nodejs/node/pull/7897
4396 - version: v4.1.0
4397 pr-url: https://github.com/nodejs/node/pull/2387
4400 -->
4415 `-Infinity`, an `Error` will be thrown.
4419 <!-- YAML
4422 - version:
4423 - v15.9.0
4424 - v14.17.0
4425 pr-url: https://github.com/nodejs/node/pull/37190
4427 - version: v7.6.0
4428 pr-url: https://github.com/nodejs/node/pull/10739
4431 - version: v7.0.0
4432 pr-url: https://github.com/nodejs/node/pull/7831
4434 -->
4474 <!--type=misc-->
4488 <!--type=misc-->
4513 <!--type=misc-->
4527 <!--type=misc-->
4535 import { watch } from 'node:fs';
4548 <!-- YAML
4551 - version: v10.5.0
4552 pr-url: https://github.com/nodejs/node/pull/20220
4554 - version: v7.6.0
4555 pr-url: https://github.com/nodejs/node/pull/10739
4558 -->
4583 import { watchFile } from 'node:fs';
4619 <!-- YAML
4622 - version: v18.0.0
4623 pr-url: https://github.com/nodejs/node/pull/41678
4627 - version: v14.0.0
4628 pr-url: https://github.com/nodejs/node/pull/31030
4631 - version: v10.10.0
4632 pr-url: https://github.com/nodejs/node/pull/22150
4635 - version: v10.0.0
4636 pr-url: https://github.com/nodejs/node/pull/12562
4639 - version: v7.4.0
4640 pr-url: https://github.com/nodejs/node/pull/10382
4642 - version: v7.2.0
4643 pr-url: https://github.com/nodejs/node/pull/7856
4645 - version: v7.0.0
4646 pr-url: https://github.com/nodejs/node/pull/7897
4649 -->
4654 * `length` {integer} **Default:** `buffer.byteLength - offset`
4673 If this method is invoked as its [`util.promisify()`][]ed version, it returns
4686 <!-- YAML
4688 -->
4694 * `length` {integer} **Default:** `buffer.byteLength - offset`
4703 Similar to the above `fs.write` function, this version takes an
4709 <!-- YAML
4712 - version: v17.8.0
4713 pr-url: https://github.com/nodejs/node/pull/42149
4716 - version: v14.12.0
4717 pr-url: https://github.com/nodejs/node/pull/34993
4720 - version: v14.0.0
4721 pr-url: https://github.com/nodejs/node/pull/31030
4724 - version: v10.0.0
4725 pr-url: https://github.com/nodejs/node/pull/12562
4728 - version: v7.2.0
4729 pr-url: https://github.com/nodejs/node/pull/7856
4731 - version: v7.0.0
4732 pr-url: https://github.com/nodejs/node/pull/7897
4735 -->
4769 or `stdout`) a string containing non-ASCII characters will not be rendered
4771 It is possible to configure the console to render UTF-8 properly by changing the
4777 <!-- YAML
4780 - version: v18.0.0
4781 pr-url: https://github.com/nodejs/node/pull/41678
4785 - version: v17.8.0
4786 pr-url: https://github.com/nodejs/node/pull/42149
4789 - version: v16.0.0
4790 pr-url: https://github.com/nodejs/node/pull/37460
4793 - version:
4794 - v15.2.0
4795 - v14.17.0
4796 pr-url: https://github.com/nodejs/node/pull/35993
4799 - version: v14.12.0
4800 pr-url: https://github.com/nodejs/node/pull/34993
4803 - version: v14.0.0
4804 pr-url: https://github.com/nodejs/node/pull/31030
4807 - version: v10.10.0
4808 pr-url: https://github.com/nodejs/node/pull/22150
4811 - version: v10.0.0
4812 pr-url: https://github.com/nodejs/node/pull/12562
4815 - version: v7.4.0
4816 pr-url: https://github.com/nodejs/node/pull/10382
4818 - version: v7.0.0
4819 pr-url: https://github.com/nodejs/node/pull/7897
4822 - version: v5.0.0
4823 pr-url: https://github.com/nodejs/node/pull/3163
4825 -->
4833 * `signal` {AbortSignal} allows aborting an in-progress writeFile
4850 import { writeFile } from 'node:fs';
4851 import { Buffer } from 'node:buffer';
4853 const data = new Uint8Array(Buffer.from('Hello Node.js'));
4863 import { writeFile } from 'node:fs';
4865 writeFile('message.txt', 'Hello Node.js', 'utf8', callback);
4872 Similarly to `fs.readFile` - `fs.writeFile` is a convenience method that
4881 import { writeFile } from 'node:fs';
4882 import { Buffer } from 'node:buffer';
4886 const data = new Uint8Array(Buffer.from('Hello Node.js'));
4888 // When a request is aborted - the callback is called with an AbortError
4903 import { write } from 'node:fs';
4904 import { Buffer } from 'node:buffer';
4928 <!-- YAML
4931 - version: v18.0.0
4932 pr-url: https://github.com/nodejs/node/pull/41678
4936 -->
4973 <!-- YAML
4976 - version: v7.6.0
4977 pr-url: https://github.com/nodejs/node/pull/10739
4980 -->
4997 import { accessSync, constants } from 'node:fs';
5009 <!-- YAML
5012 - version: v7.0.0
5013 pr-url: https://github.com/nodejs/node/pull/7831
5015 - version: v5.0.0
5016 pr-url: https://github.com/nodejs/node/pull/3163
5018 -->
5034 import { appendFileSync } from 'node:fs';
5047 import { appendFileSync } from 'node:fs';
5057 import { openSync, closeSync, appendFileSync } from 'node:fs';
5074 <!-- YAML
5077 - version: v7.6.0
5078 pr-url: https://github.com/nodejs/node/pull/10739
5081 -->
5086 For detailed information, see the documentation of the asynchronous version of
5093 <!-- YAML
5096 - version: v7.6.0
5097 pr-url: https://github.com/nodejs/node/pull/10739
5100 -->
5107 This is the synchronous version of [`fs.chown()`][].
5113 <!-- YAML
5115 -->
5128 <!-- YAML
5131 - version: v14.0.0
5132 pr-url: https://github.com/nodejs/node/pull/27044
5135 -->
5142 already exists. Returns `undefined`. Node.js makes no guarantees about the
5144 has been opened for writing, Node.js will attempt to remove the destination.
5154 copy-on-write reflink. If the platform does not support copy-on-write, then a
5157 create a copy-on-write reflink. If the platform does not support
5158 copy-on-write, then the operation will fail.
5161 import { copyFileSync, constants } from 'node:fs';
5173 <!-- YAML
5176 - version: v18.17.0
5177 pr-url: https://github.com/nodejs/node/pull/47084
5180 - version: v17.6.0
5181 pr-url: https://github.com/nodejs/node/pull/41819
5184 -->
5186 > Stability: 1 - Experimental
5220 <!-- YAML
5223 - version: v7.6.0
5224 pr-url: https://github.com/nodejs/node/pull/10739
5227 -->
5234 For detailed information, see the documentation of the asynchronous version of
5239 Node.js callbacks. `fs.existsSync()` does not use a callback.
5242 import { existsSync } from 'node:fs';
5250 <!-- YAML
5252 -->
5263 <!-- YAML
5265 -->
5277 <!-- YAML
5279 -->
5289 <!-- YAML
5292 - version: v10.5.0
5293 pr-url: https://github.com/nodejs/node/pull/20220
5296 -->
5310 <!-- YAML
5312 -->
5322 <!-- YAML
5324 -->
5331 For detailed information, see the documentation of the asynchronous version of
5336 <!-- YAML
5339 - version: v4.1.0
5340 pr-url: https://github.com/nodejs/node/pull/2387
5343 -->
5349 Synchronous version of [`fs.futimes()`][]. Returns `undefined`.
5353 <!-- YAML
5355 -->
5368 <!-- YAML
5370 - version: v10.6.0
5371 pr-url: https://github.com/nodejs/node/pull/21498
5373 - version: v0.4.7
5374 description: Documentation-only deprecation.
5375 -->
5387 <!-- YAML
5389 - v14.5.0
5390 - v12.19.0
5391 -->
5399 the operation fails. This is the synchronous version of [`fs.lutimes()`][].
5403 <!-- YAML
5406 - version: v7.6.0
5407 pr-url: https://github.com/nodejs/node/pull/10739
5411 -->
5421 <!-- YAML
5424 - version:
5425 - v15.3.0
5426 - v14.17.0
5427 pr-url: https://github.com/nodejs/node/pull/33716
5430 - version: v10.5.0
5431 pr-url: https://github.com/nodejs/node/pull/20220
5434 - version: v7.6.0
5435 pr-url: https://github.com/nodejs/node/pull/10739
5438 -->
5455 <!-- YAML
5458 - version:
5459 - v13.11.0
5460 - v12.17.0
5461 pr-url: https://github.com/nodejs/node/pull/31530
5463 - version: v10.12.0
5464 pr-url: https://github.com/nodejs/node/pull/21875
5467 - version: v7.6.0
5468 pr-url: https://github.com/nodejs/node/pull/10739
5471 -->
5481 This is the synchronous version of [`fs.mkdir()`][].
5487 <!-- YAML
5490 - version: v18.19.0
5491 pr-url: https://github.com/nodejs/node/pull/48828
5493 - version:
5494 - v16.5.0
5495 - v14.18.0
5496 pr-url: https://github.com/nodejs/node/pull/39028
5498 -->
5507 For detailed information, see the documentation of the asynchronous version of
5515 <!-- YAML
5518 - version: v18.17.0
5519 pr-url: https://github.com/nodejs/node/pull/41439
5521 - version:
5522 - v13.1.0
5523 - v12.16.0
5524 pr-url: https://github.com/nodejs/node/pull/30114
5526 -->
5547 <!-- YAML
5550 - version: v11.1.0
5551 pr-url: https://github.com/nodejs/node/pull/23767
5553 - version: v9.9.0
5554 pr-url: https://github.com/nodejs/node/pull/18801
5556 - version: v7.6.0
5557 pr-url: https://github.com/nodejs/node/pull/10739
5560 -->
5570 For detailed information, see the documentation of the asynchronous version of
5575 <!-- YAML
5578 - version: v18.17.0
5579 pr-url: https://github.com/nodejs/node/pull/41439
5581 - version: v10.10.0
5582 pr-url: https://github.com/nodejs/node/pull/22020
5584 - version: v7.6.0
5585 pr-url: https://github.com/nodejs/node/pull/10739
5588 -->
5611 <!-- YAML
5614 - version: v7.6.0
5615 pr-url: https://github.com/nodejs/node/pull/10739
5618 - version: v5.0.0
5619 pr-url: https://github.com/nodejs/node/pull/3163
5621 -->
5631 For detailed information, see the documentation of the asynchronous version of
5638 `fs.readFileSync()` is platform-specific.
5641 import { readFileSync } from 'node:fs';
5653 <!-- YAML
5656 - version: v7.6.0
5657 pr-url: https://github.com/nodejs/node/pull/10739
5660 -->
5678 <!-- YAML
5681 - version: v10.10.0
5682 pr-url: https://github.com/nodejs/node/pull/22150
5685 - version: v6.0.0
5686 pr-url: https://github.com/nodejs/node/pull/4518
5688 -->
5699 For detailed information, see the documentation of the asynchronous version of
5704 <!-- YAML
5706 - v13.13.0
5707 - v12.17.0
5709 - version:
5710 - v13.13.0
5711 - v12.17.0
5712 pr-url: https://github.com/nodejs/node/pull/32460
5715 -->
5721 * `length` {integer} **Default:** `buffer.byteLength - offset`
5727 Similar to the above `fs.readSync` function, this version takes an optional `options` object.
5730 For detailed information, see the documentation of the asynchronous version of
5735 <!-- YAML
5737 - v13.13.0
5738 - v12.17.0
5739 -->
5746 For detailed information, see the documentation of the asynchronous version of
5751 <!-- YAML
5754 - version: v8.0.0
5755 pr-url: https://github.com/nodejs/node/pull/13028
5757 - version: v7.6.0
5758 pr-url: https://github.com/nodejs/node/pull/10739
5761 - version: v6.4.0
5762 pr-url: https://github.com/nodejs/node/pull/7899
5765 - version: v6.0.0
5766 pr-url: https://github.com/nodejs/node/pull/3594
5768 -->
5777 For detailed information, see the documentation of the asynchronous version of
5782 <!-- YAML
5784 -->
5800 On Linux, when Node.js is linked against musl libc, the procfs file system must
5806 <!-- YAML
5809 - version: v7.6.0
5810 pr-url: https://github.com/nodejs/node/pull/10739
5814 -->
5825 <!-- YAML
5828 - version: v16.0.0
5829 pr-url: https://github.com/nodejs/node/pull/37216
5833 - version: v16.0.0
5834 pr-url: https://github.com/nodejs/node/pull/37216
5838 - version: v16.0.0
5839 pr-url: https://github.com/nodejs/node/pull/37302
5842 - version: v14.14.0
5843 pr-url: https://github.com/nodejs/node/pull/35579
5845 - version:
5846 - v13.3.0
5847 - v12.16.0
5848 pr-url: https://github.com/nodejs/node/pull/30644
5854 - version: v12.10.0
5855 pr-url: https://github.com/nodejs/node/pull/29168
5858 - version: v7.6.0
5859 pr-url: https://github.com/nodejs/node/pull/10739
5862 -->
5867 `EPERM` error is encountered, Node.js retries the operation with a linear
5883 To get a behavior similar to the `rm -rf` Unix command, use [`fs.rmSync()`][]
5888 <!-- YAML
5891 - version:
5892 - v17.3.0
5893 - v16.14.0
5894 pr-url: https://github.com/nodejs/node/pull/41132
5897 -->
5904 `EPERM` error is encountered, Node.js will retry the operation with a linear
5919 <!-- YAML
5922 - version:
5923 - v15.3.0
5924 - v14.17.0
5925 pr-url: https://github.com/nodejs/node/pull/33716
5928 - version: v10.5.0
5929 pr-url: https://github.com/nodejs/node/pull/20220
5932 - version: v7.6.0
5933 pr-url: https://github.com/nodejs/node/pull/10739
5936 -->
5951 <!-- YAML
5953 -->
5968 <!-- YAML
5971 - version: v12.0.0
5972 pr-url: https://github.com/nodejs/node/pull/23724
5973 description: If the `type` argument is left undefined, Node will autodetect
5975 - version: v7.6.0
5976 pr-url: https://github.com/nodejs/node/pull/10739
5980 -->
5988 For detailed information, see the documentation of the asynchronous version of
5993 <!-- YAML
5995 -->
6008 <!-- YAML
6011 - version: v7.6.0
6012 pr-url: https://github.com/nodejs/node/pull/10739
6015 -->
6023 <!-- YAML
6026 - version: v8.0.0
6027 pr-url: https://github.com/nodejs/node/pull/11919
6028 description: "`NaN`, `Infinity`, and `-Infinity` are no longer valid time
6030 - version: v7.6.0
6031 pr-url: https://github.com/nodejs/node/pull/10739
6034 - version: v4.1.0
6035 pr-url: https://github.com/nodejs/node/pull/2387
6038 -->
6046 For detailed information, see the documentation of the asynchronous version of
6051 <!-- YAML
6054 - version: v17.8.0
6055 pr-url: https://github.com/nodejs/node/pull/42149
6058 - version: v14.12.0
6059 pr-url: https://github.com/nodejs/node/pull/34993
6062 - version: v14.0.0
6063 pr-url: https://github.com/nodejs/node/pull/31030
6066 - version: v10.10.0
6067 pr-url: https://github.com/nodejs/node/pull/22150
6070 - version: v7.4.0
6071 pr-url: https://github.com/nodejs/node/pull/10382
6073 - version: v5.0.0
6074 pr-url: https://github.com/nodejs/node/pull/3163
6076 -->
6090 For detailed information, see the documentation of the asynchronous version of
6095 <!-- YAML
6098 - version: v14.0.0
6099 pr-url: https://github.com/nodejs/node/pull/31030
6102 - version: v10.10.0
6103 pr-url: https://github.com/nodejs/node/pull/22150
6106 - version: v7.4.0
6107 pr-url: https://github.com/nodejs/node/pull/10382
6109 - version: v7.2.0
6110 pr-url: https://github.com/nodejs/node/pull/7856
6112 -->
6117 * `length` {integer} **Default:** `buffer.byteLength - offset`
6121 For detailed information, see the documentation of the asynchronous version of
6126 <!-- YAML
6128 -->
6134 * `length` {integer} **Default:** `buffer.byteLength - offset`
6138 For detailed information, see the documentation of the asynchronous version of
6143 <!-- YAML
6146 - version: v14.0.0
6147 pr-url: https://github.com/nodejs/node/pull/31030
6150 - version: v7.2.0
6151 pr-url: https://github.com/nodejs/node/pull/7856
6153 -->
6161 For detailed information, see the documentation of the asynchronous version of
6166 <!-- YAML
6168 -->
6175 For detailed information, see the documentation of the asynchronous version of
6185 <!-- YAML
6187 -->
6195 import { opendir } from 'node:fs/promises';
6211 <!-- YAML
6213 -->
6225 <!-- YAML
6228 - version: v18.0.0
6229 pr-url: https://github.com/nodejs/node/pull/41678
6233 -->
6245 <!-- YAML
6247 -->
6254 <!-- YAML
6256 -->
6260 The read-only path of this directory as was provided to [`fs.opendir()`][],
6265 <!-- YAML
6267 -->
6284 <!-- YAML
6286 -->
6305 <!-- YAML
6307 -->
6323 <!-- YAML
6325 -->
6344 <!-- YAML
6346 -->
6358 <!-- YAML
6360 -->
6368 <!-- YAML
6370 -->
6378 <!-- YAML
6380 -->
6389 <!-- YAML
6391 -->
6395 Returns `true` if the {fs.Dirent} object describes a first-in-first-out
6400 <!-- YAML
6402 -->
6410 <!-- YAML
6412 -->
6420 <!-- YAML
6422 -->
6430 <!-- YAML
6432 -->
6442 <!-- YAML
6444 - v18.20.0
6445 -->
6455 <!-- YAML
6458 -->
6460 > Stability: 0 - Deprecated: Use [`dirent.parentPath`][] instead.
6468 <!-- YAML
6470 -->
6482 <!-- YAML
6484 -->
6495 `filename` will be a UTF-8 string.
6498 import { watch } from 'node:fs';
6510 <!-- YAML
6512 -->
6519 <!-- YAML
6521 -->
6530 <!-- YAML
6532 -->
6539 <!-- YAML
6541 - v14.3.0
6542 - v12.20.0
6543 -->
6547 When called, requests that the Node.js event loop _not_ exit so long as the
6557 <!-- YAML
6559 - v14.3.0
6560 - v12.20.0
6561 -->
6565 When called, the active {fs.FSWatcher} object will not require the Node.js
6573 <!-- YAML
6575 - v14.3.0
6576 - v12.20.0
6577 -->
6586 <!-- YAML
6588 - v14.3.0
6589 - v12.20.0
6590 -->
6594 When called, requests that the Node.js event loop _not_ exit so long as the
6604 <!-- YAML
6606 - v14.3.0
6607 - v12.20.0
6608 -->
6612 When called, the active {fs.StatWatcher} object will not require the Node.js
6620 <!-- YAML
6622 -->
6631 <!-- YAML
6633 -->
6639 <!-- YAML
6641 -->
6649 <!-- YAML
6651 -->
6659 <!-- YAML
6661 -->
6669 <!-- YAML
6671 -->
6683 <!-- YAML
6685 - v11.2.0
6686 - v10.16.0
6687 -->
6696 <!-- YAML
6699 - version: v8.1.0
6700 pr-url: https://github.com/nodejs/node/pull/13173
6702 -->
6710 nanosecond-precision properties suffixed with `Ns`.
6734 `bigint` version:
6764 <!-- YAML
6766 -->
6774 <!-- YAML
6776 -->
6784 <!-- YAML
6786 -->
6798 <!-- YAML
6800 -->
6804 Returns `true` if the {fs.Stats} object describes a first-in-first-out (FIFO)
6809 <!-- YAML
6811 -->
6819 <!-- YAML
6821 -->
6829 <!-- YAML
6831 -->
6855 A bit-field describing the file type and mode.
6861 The number of hard-links that exist for the file.
6904 <!-- YAML
6906 -->
6915 <!-- YAML
6917 -->
6926 <!-- YAML
6928 -->
6937 <!-- YAML
6939 -->
6948 <!-- YAML
6950 -->
6961 <!-- YAML
6963 -->
6974 <!-- YAML
6976 -->
6987 <!-- YAML
6989 -->
7000 <!-- YAML
7002 -->
7010 <!-- YAML
7012 -->
7020 <!-- YAML
7022 -->
7030 <!-- YAML
7032 -->
7044 otherwise they will be [numbers][MDN-Number].
7052 [`Date`][MDN-Date] object alternate representations of the various times. The
7070 `1970-01-01T00:00Z` (ie, Unix epoch timestamp `0`). This value may be greater
7075 Prior to Node.js 0.12, the `ctime` held the `birthtime` on Windows systems. As
7080 <!-- YAML
7082 -->
7102 `bigint` version:
7118 <!-- YAML
7120 -->
7128 <!-- YAML
7130 -->
7138 <!-- YAML
7140 -->
7148 <!-- YAML
7150 -->
7158 <!-- YAML
7160 -->
7168 <!-- YAML
7170 -->
7178 <!-- YAML
7180 -->
7188 <!-- YAML
7190 -->
7199 <!-- YAML
7201 -->
7207 <!-- YAML
7209 -->
7217 <!-- YAML
7219 -->
7227 <!-- YAML
7229 -->
7236 <!-- YAML
7238 -->
7249 <!-- YAML
7251 -->
7260 <!-- YAML
7262 -->
7291 import { open, constants } from 'node:fs';
7356 copy-on-write reflink. If the underlying platform does not support
7357 copy-on-write, then a fallback copy mechanism is used.</td>
7362 copy-on-write reflink. If the underlying platform does not support
7363 copy-on-write, then the operation will fail with an error.</td>
7380 <td>Flag indicating to open a file for read-only access.</td>
7384 <td>Flag indicating to open a file for write-only access.</td>
7388 <td>Flag indicating to open a file for read-write access.</td>
7490 <td>File type constant for a character-oriented device file.</td>
7494 <td>File type constant for a block-oriented device file.</td>
7577 ### Ordering of callback and promise-based operations
7581 promise-based methods.
7587 const fs = require('node:fs');
7603 import { rename, stat } from 'node:fs/promises';
7618 const { rename, stat } = require('node:fs/promises');
7635 import { rename, stat } from 'node:fs';
7647 const { rename, stat } = require('node:fs/promises');
7665 String paths are interpreted as UTF-8 character sequences identifying
7672 import { open } from 'node:fs/promises';
7686 import { open } from 'node:fs/promises';
7699 <!-- YAML
7701 -->
7703 For most `node:fs` module functions, the `path` or `filename` argument may be
7707 import { readFileSync } from 'node:fs';
7714 ##### Platform-specific considerations
7721 import { readFileSync } from 'node:fs';
7724 // - WHATWG file URLs with hostname convert to UNC path
7728 // - WHATWG file URLs with drive letters convert to absolute path
7732 // - WHATWG file URLs without hostname must have a drive letters
7745 import { readFileSync } from 'node:fs';
7748 // - WHATWG file URLs with hostname are unsupported
7753 // - WHATWG file URLs convert to absolute path
7762 import { readFileSync } from 'node:fs';
7780 import { readFileSync } from 'node:fs';
7793 systems, it is possible for a single file path to contain sub-sequences that
7800 import { open } from 'node:fs/promises';
7801 import { Buffer } from 'node:buffer';
7812 #### Per-drive working directories on Windows
7814 On Windows, Node.js follows the concept of per-drive working directory. This
7818 [this MSDN page][MSDN-Rel-Path].
7824 identifier called a _file descriptor_. At the system-level, all file system
7827 tracking resources. To simplify things for users, Node.js abstracts away the
7831 The callback-based `fs.open()`, and synchronous `fs.openSync()` methods open a
7841 import { open, close, fstat } from 'node:fs';
7869 The promise-based APIs use a {FileHandle} object in place of the numeric
7875 import { open } from 'node:fs/promises';
7889 All callback and promise-based file system APIs (with the exception of
7962 The behavior of some flags are platform-specific. As such, opening a directory
7986 [#25741]: https://github.com/nodejs/node/issues/25741
7987 [Common System Errors]: errors.md#common-system-errors
7988 [FS constants]: #fs-constants
7989 [File access constants]: #file-access-constants
7990 [MDN-Date]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
7991 [MDN-Number]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type
7992 [MSDN-Rel-Path]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#fully-qualif…
7993 [MSDN-Using-Streams]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams
7994 …iles, Paths, and Namespaces]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file
7995 [`AHAFS`]: https://developer.ibm.com/articles/au-aix_event_infrastructure/
7996 [`Buffer.byteLength`]: buffer.md#static-method-bufferbytelengthstring-encoding
7998 [`Number.MAX_SAFE_INTEGER`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Glob…
7999 [`ReadDirectoryChangesW`]: https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-
8005 [`filehandle.writeFile()`]: #filehandlewritefiledata-options
8006 [`fs.access()`]: #fsaccesspath-mode-callback
8007 [`fs.accessSync()`]: #fsaccesssyncpath-mode
8008 [`fs.chmod()`]: #fschmodpath-mode-callback
8009 [`fs.chown()`]: #fschownpath-uid-gid-callback
8010 [`fs.copyFile()`]: #fscopyfilesrc-dest-mode-callback
8011 [`fs.copyFileSync()`]: #fscopyfilesyncsrc-dest-mode
8012 [`fs.createReadStream()`]: #fscreatereadstreampath-options
8013 [`fs.createWriteStream()`]: #fscreatewritestreampath-options
8014 [`fs.exists()`]: #fsexistspath-callback
8015 [`fs.fstat()`]: #fsfstatfd-options-callback
8016 [`fs.ftruncate()`]: #fsftruncatefd-len-callback
8017 [`fs.futimes()`]: #fsfutimesfd-atime-mtime-callback
8018 [`fs.lstat()`]: #fslstatpath-options-callback
8019 [`fs.lutimes()`]: #fslutimespath-atime-mtime-callback
8020 [`fs.mkdir()`]: #fsmkdirpath-options-callback
8021 [`fs.mkdtemp()`]: #fsmkdtempprefix-options-callback
8022 [`fs.open()`]: #fsopenpath-flags-mode-callback
8023 [`fs.opendir()`]: #fsopendirpath-options-callback
8024 [`fs.opendirSync()`]: #fsopendirsyncpath-options
8025 [`fs.read()`]: #fsreadfd-buffer-offset-length-position-callback
8026 [`fs.readFile()`]: #fsreadfilepath-options-callback
8027 [`fs.readFileSync()`]: #fsreadfilesyncpath-options
8028 [`fs.readdir()`]: #fsreaddirpath-options-callback
8029 [`fs.readdirSync()`]: #fsreaddirsyncpath-options
8030 [`fs.readv()`]: #fsreadvfd-buffers-position-callback
8031 [`fs.realpath()`]: #fsrealpathpath-options-callback
8032 [`fs.rm()`]: #fsrmpath-options-callback
8033 [`fs.rmSync()`]: #fsrmsyncpath-options
8034 [`fs.rmdir()`]: #fsrmdirpath-options-callback
8035 [`fs.stat()`]: #fsstatpath-options-callback
8036 [`fs.statfs()`]: #fsstatfspath-options-callback
8037 [`fs.symlink()`]: #fssymlinktarget-path-type-callback
8038 [`fs.utimes()`]: #fsutimespath-atime-mtime-callback
8039 [`fs.watch()`]: #fswatchfilename-options-listener
8040 [`fs.write(fd, buffer...)`]: #fswritefd-buffer-offset-length-position-callback
8041 [`fs.write(fd, string...)`]: #fswritefd-string-position-encoding-callback
8042 [`fs.writeFile()`]: #fswritefilefile-data-options-callback
8043 [`fs.writev()`]: #fswritevfd-buffers-position-callback
8044 [`fsPromises.access()`]: #fspromisesaccesspath-mode
8045 [`fsPromises.copyFile()`]: #fspromisescopyfilesrc-dest-mode
8046 [`fsPromises.open()`]: #fspromisesopenpath-flags-mode
8047 [`fsPromises.opendir()`]: #fspromisesopendirpath-options
8048 [`fsPromises.rm()`]: #fspromisesrmpath-options
8049 [`fsPromises.stat()`]: #fspromisesstatpath-options
8050 [`fsPromises.utimes()`]: #fspromisesutimespath-atime-mtime
8051 [`inotify(7)`]: https://man7.org/linux/man-pages/man7/inotify.7.html
8054 [bigints]: https://tc39.github.io/proposal-bigint
8058 [support of file system `flags`]: #file-system-flags