Cách mở đường dẫn tệp trong javascript

open() thường tiêu tốn một lượng lớn bộ nhớ vì mỗi VU giữ một bản sao riêng của tệp trong bộ nhớ. Để giảm mức tiêu thụ bộ nhớ, chúng tôi thực sự khuyên bạn nên sử dụng SharedArray cho CSV, JSON và các tệp khác dành cho tham số hóa tập lệnh

Chức năng chỉ khả dụng trong "bối cảnh khởi tạo"

Đây là một hàm chỉ có thể được gọi từ ngữ cảnh init (còn gọi là mã khởi tạo), mã trong ngữ cảnh chung, bên ngoài hàm mặc định xuất chính {. }

Bằng cách giới hạn nó trong ngữ cảnh init, chúng tôi có thể dễ dàng xác định tệp cục bộ nào cần thiết để chạy thử nghiệm và do đó, chúng tôi cần gói gì khi phân phối thử nghiệm cho nhiều nút trong thử nghiệm phân cụm/phân tán

Xem thêm ví dụ trên trang này. Để có mô tả chi tiết hơn, hãy xem Running k6

Thay đổi lớn trong v0. 36. 0

kể từ k6 v0. 36. 0, các VU hiện chỉ bị hạn chế đối với các tệp open() cũng được mở trong ngữ cảnh ban đầu của VU đầu tiên - tệp được khởi tạo để nhận các tùy chọn đã xuất từ ​​tập lệnh JS (__VU==0). Điều này có nghĩa là đoạn mã như if (__VU > 0) { const arr = open(". /arr. json"); } sẽ dẫn đến lỗi

ParameterTypeDescriptionfilePathstringThe path to the file, absolute or relative, that will be read into memory. The file will only be loaded once, even when running with several VUs. modestringBy default, the contents of the file are read as text, but if you specify b, the file will be read as binary data instead

Returns

TypeDescriptionstring / ArrayBufferThe contents of the file, returned as string or ArrayBuffer (if b was specified as the mode)

Breaking change in v0. 32. 0

Since k6 v0. 32. 0 mở (. , 'b') trả về một đối tượng ArrayBuffer thay vì một mảng số (byte). Nếu bạn cần thao tác dữ liệu nhị phân, bạn sẽ cần bọc đối tượng ArrayBuffer trong chế độ xem mảng đã nhập

Mô-đun

import { open } from 'node:fs/promises';

const fd = await open('sample.txt');
fd.createReadStream({ start: 90, end: 99 });
4 cho phép tương tác với hệ thống tệp theo cách được mô hình hóa trên các chức năng POSIX tiêu chuẩn

Để sử dụng các API dựa trên lời hứa

import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');

Để sử dụng API gọi lại và đồng bộ hóa

import * as fs from 'node:fs';const fs = require('node:fs');

Tất cả các hoạt động của hệ thống tệp đều có biểu mẫu đồng bộ, gọi lại và dựa trên lời hứa và có thể truy cập bằng cả cú pháp CommonJS và Mô-đun ES6 (ESM)

Ví dụ hứa hẹn #

Các hoạt động dựa trên lời hứa trả về một lời hứa được thực hiện khi hoạt động không đồng bộ hoàn tất

import { unlink } from 'node:fs/promises';

try {
  await unlink('/tmp/hello');
  console.log('successfully deleted /tmp/hello');
} catch (error) {
  console.error('there was an error:', error.message);
}const { unlink } = require('node:fs/promises');

(async function(path) {
  try {
    await unlink(path);
    console.log(`successfully deleted ${path}`);
  } catch (error) {
    console.error('there was an error:', error.message);
  }
})('/tmp/hello');

Ví dụ gọi lại #

Biểu mẫu gọi lại lấy hàm gọi lại hoàn thành làm đối số cuối cùng của nó và gọi hoạt động không đồng bộ. Các đối số được truyền cho lệnh gọi lại hoàn thành phụ thuộc vào phương thức, nhưng đối số đầu tiên luôn được dành riêng cho một ngoại lệ. Nếu thao tác hoàn tất thành công, thì đối số đầu tiên là

import { open } from 'node:fs/promises';

const fd = await open('sample.txt');
fd.createReadStream({ start: 90, end: 99 });
5 hoặc
import { open } from 'node:fs/promises';

const fd = await open('sample.txt');
fd.createReadStream({ start: 90, end: 99 });
6

import { unlink } from 'node:fs';

unlink('/tmp/hello', (err) => {
  if (err) throw err;
  console.log('successfully deleted /tmp/hello');
});const { unlink } = require('node:fs');

unlink('/tmp/hello', (err) => {
  if (err) throw err;
  console.log('successfully deleted /tmp/hello');
});

Các phiên bản dựa trên gọi lại của API mô-đun

import { open } from 'node:fs/promises';

const fd = await open('sample.txt');
fd.createReadStream({ start: 90, end: 99 });
4 được ưu tiên sử dụng hơn so với việc sử dụng các API hứa hẹn khi hiệu suất tối đa (cả về thời gian thực hiện và cấp phát bộ nhớ) là bắt buộc

Ví dụ đồng bộ#

Các API đồng bộ chặn Nút. js và thực thi JavaScript tiếp theo cho đến khi thao tác hoàn tất. Các ngoại lệ được đưa ra ngay lập tức và có thể được xử lý bằng cách sử dụng

import { open } from 'node:fs/promises';

const fd = await open('sample.txt');
fd.createReadStream({ start: 90, end: 99 });
8 hoặc có thể được phép nổi lên

API hứa hẹn #

Lịch sửPhiên bảnChangesv14. 0. 0

tiếp xúc như

import { open } from 'node:fs/promises';

const fd = await open('sample.txt');
fd.createReadStream({ start: 90, end: 99 });
9

v11. 14. 0, v10. 17. 0

API này không còn thử nghiệm nữa

v10. 1. 0

API chỉ có thể truy cập qua

import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
00

v10. 0. 0

Đã thêm vào. v10. 0. 0

API

import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
01 cung cấp các phương thức hệ thống tệp không đồng bộ trả về lời hứa

The promise APIs use the underlying Node. js threadpool to perform file system operations off the event loop thread. These operations are not synchronized or threadsafe. Care must be taken when performing multiple concurrent modifications on the same file or data corruption may occur

Class.
import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
02#

A object is an object wrapper for a numeric file descriptor

Instances of the object are created by the

import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
03 method

All objects are s

If a is not closed using the

import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
04 method, it will try to automatically close the file descriptor and emit a process warning, helping to prevent memory leaks. Please do not rely on this behavior because it can be unreliable and the file may not be closed. Instead, always explicitly close s. Node. js may change this behavior in the future

Event.
import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
05#

The

import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
05 event is emitted when the has been closed and can no longer be used

import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
07#

HistoryVersionChangesv15. 14. 0, v14. 18. 0

The

import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
08 argument supports
import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
09,
import * as fs from 'node:fs';const fs = require('node:fs');
00, and
import * as fs from 'node:fs';const fs = require('node:fs');
01

v14. 0. 0

The

import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
08 parameter won't coerce unsupported input to strings anymore

v10. 0. 0

Đã thêm vào. v10. 0. 0

Alias of

import * as fs from 'node:fs';const fs = require('node:fs');
03

When operating on file handles, the mode cannot be changed from what it was set to with

import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
03. Therefore, this is equivalent to
import * as fs from 'node:fs';const fs = require('node:fs');
03

import * as fs from 'node:fs';const fs = require('node:fs');
06#

Modifies the permissions on the file. See

import * as fs from 'node:fs';const fs = require('node:fs');
07

import * as fs from 'node:fs';const fs = require('node:fs');
08#
  • import * as fs from 'node:fs';const fs = require('node:fs');
    09 The file's new owner's user id
  • import { unlink } from 'node:fs/promises';
    
    try {
      await unlink('/tmp/hello');
      console.log('successfully deleted /tmp/hello');
    } catch (error) {
      console.error('there was an error:', error.message);
    }const { unlink } = require('node:fs/promises');
    
    (async function(path) {
      try {
        await unlink(path);
        console.log(`successfully deleted ${path}`);
      } catch (error) {
        console.error('there was an error:', error.message);
      }
    })('/tmp/hello');
    00 The file's new group's group id
  • Returns. Fulfills with
    import { open } from 'node:fs/promises';
    
    const fd = await open('sample.txt');
    fd.createReadStream({ start: 90, end: 99 });
    6 upon success

Changes the ownership of the file. A wrapper for

import { unlink } from 'node:fs/promises';

try {
  await unlink('/tmp/hello');
  console.log('successfully deleted /tmp/hello');
} catch (error) {
  console.error('there was an error:', error.message);
}const { unlink } = require('node:fs/promises');

(async function(path) {
  try {
    await unlink(path);
    console.log(`successfully deleted ${path}`);
  } catch (error) {
    console.error('there was an error:', error.message);
  }
})('/tmp/hello');
02

import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
04#
  • Returns. Fulfills with
    import { open } from 'node:fs/promises';
    
    const fd = await open('sample.txt');
    fd.createReadStream({ start: 90, end: 99 });
    6 upon success

Closes the file handle after waiting for any pending operation on the handle to complete

import { unlink } from 'node:fs/promises';

try {
  await unlink('/tmp/hello');
  console.log('successfully deleted /tmp/hello');
} catch (error) {
  console.error('there was an error:', error.message);
}const { unlink } = require('node:fs/promises');

(async function(path) {
  try {
    await unlink(path);
    console.log(`successfully deleted ${path}`);
  } catch (error) {
    console.error('there was an error:', error.message);
  }
})('/tmp/hello');
5
import { unlink } from 'node:fs/promises';

try {
  await unlink('/tmp/hello');
  console.log('successfully deleted /tmp/hello');
} catch (error) {
  console.error('there was an error:', error.message);
}const { unlink } = require('node:fs/promises');

(async function(path) {
  try {
    await unlink(path);
    console.log(`successfully deleted ${path}`);
  } catch (error) {
    console.error('there was an error:', error.message);
  }
})('/tmp/hello');
05#

Unlike the 16 KiB default

import { unlink } from 'node:fs/promises';

try {
  await unlink('/tmp/hello');
  console.log('successfully deleted /tmp/hello');
} catch (error) {
  console.error('there was an error:', error.message);
}const { unlink } = require('node:fs/promises');

(async function(path) {
  try {
    await unlink(path);
    console.log(`successfully deleted ${path}`);
  } catch (error) {
    console.error('there was an error:', error.message);
  }
})('/tmp/hello');
06 for a , the stream returned by this method has a default
import { unlink } from 'node:fs/promises';

try {
  await unlink('/tmp/hello');
  console.log('successfully deleted /tmp/hello');
} catch (error) {
  console.error('there was an error:', error.message);
}const { unlink } = require('node:fs/promises');

(async function(path) {
  try {
    await unlink(path);
    console.log(`successfully deleted ${path}`);
  } catch (error) {
    console.error('there was an error:', error.message);
  }
})('/tmp/hello');
06 of 64 KiB

import { unlink } from 'node:fs/promises';

try {
  await unlink('/tmp/hello');
  console.log('successfully deleted /tmp/hello');
} catch (error) {
  console.error('there was an error:', error.message);
}const { unlink } = require('node:fs/promises');

(async function(path) {
  try {
    await unlink(path);
    console.log(`successfully deleted ${path}`);
  } catch (error) {
    console.error('there was an error:', error.message);
  }
})('/tmp/hello');
08 can include
import { unlink } from 'node:fs/promises';

try {
  await unlink('/tmp/hello');
  console.log('successfully deleted /tmp/hello');
} catch (error) {
  console.error('there was an error:', error.message);
}const { unlink } = require('node:fs/promises');

(async function(path) {
  try {
    await unlink(path);
    console.log(`successfully deleted ${path}`);
  } catch (error) {
    console.error('there was an error:', error.message);
  }
})('/tmp/hello');
09 and
import { open } from 'node:fs/promises';

const fd = await open('sample.txt');
fd.createReadStream({ start: 90, end: 99 });
10 values to read a range of bytes from the file instead of the entire file. Both
import { unlink } from 'node:fs/promises';

try {
  await unlink('/tmp/hello');
  console.log('successfully deleted /tmp/hello');
} catch (error) {
  console.error('there was an error:', error.message);
}const { unlink } = require('node:fs/promises');

(async function(path) {
  try {
    await unlink(path);
    console.log(`successfully deleted ${path}`);
  } catch (error) {
    console.error('there was an error:', error.message);
  }
})('/tmp/hello');
09 and
import { open } from 'node:fs/promises';

const fd = await open('sample.txt');
fd.createReadStream({ start: 90, end: 99 });
10 are inclusive and start counting at 0, allowed values are in the [0,
import { open } from 'node:fs/promises';

const fd = await open('sample.txt');
fd.createReadStream({ start: 90, end: 99 });
13] range. If
import { unlink } from 'node:fs/promises';

try {
  await unlink('/tmp/hello');
  console.log('successfully deleted /tmp/hello');
} catch (error) {
  console.error('there was an error:', error.message);
}const { unlink } = require('node:fs/promises');

(async function(path) {
  try {
    await unlink(path);
    console.log(`successfully deleted ${path}`);
  } catch (error) {
    console.error('there was an error:', error.message);
  }
})('/tmp/hello');
09 is omitted or
import { open } from 'node:fs/promises';

const fd = await open('sample.txt');
fd.createReadStream({ start: 90, end: 99 });
6,
import { open } from 'node:fs/promises';

const fd = await open('sample.txt');
fd.createReadStream({ start: 90, end: 99 });
16 reads sequentially from the current file position. The
import { open } from 'node:fs/promises';

const fd = await open('sample.txt');
fd.createReadStream({ start: 90, end: 99 });
17 can be any one of those accepted by

If the

import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
02 points to a character device that only supports blocking reads (such as keyboard or sound card), read operations do not finish until data is available. This can prevent the process from exiting and the stream from closing naturally

By default, the stream will emit a

import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
05 event after it has been destroyed. Set the
import * as fs from 'node:fs';const fs = require('node:fs');
00 option to
import * as fs from 'node:fs';const fs = require('node:fs');
01 to change this behavior

If

import * as fs from 'node:fs';const fs = require('node:fs');
02 is false, then the file descriptor won't be closed, even if there's an error. It is the application's responsibility to close it and make sure there's no file descriptor leak. If
import * as fs from 'node:fs';const fs = require('node:fs');
02 is set to true (default behavior), on
import * as fs from 'node:fs';const fs = require('node:fs');
04 or
import * as fs from 'node:fs';const fs = require('node:fs');
05 the file descriptor will be closed automatically

Một ví dụ để đọc 10 byte cuối cùng của tệp dài 100 byte

import { open } from 'node:fs/promises';

const fd = await open('sample.txt');
fd.createReadStream({ start: 90, end: 99 });
import * as fs from 'node:fs';const fs = require('node:fs');
06#

import { unlink } from 'node:fs/promises';

try {
  await unlink('/tmp/hello');
  console.log('successfully deleted /tmp/hello');
} catch (error) {
  console.error('there was an error:', error.message);
}const { unlink } = require('node:fs/promises');

(async function(path) {
  try {
    await unlink(path);
    console.log(`successfully deleted ${path}`);
  } catch (error) {
    console.error('there was an error:', error.message);
  }
})('/tmp/hello');
08 may also include a
import { unlink } from 'node:fs/promises';

try {
  await unlink('/tmp/hello');
  console.log('successfully deleted /tmp/hello');
} catch (error) {
  console.error('there was an error:', error.message);
}const { unlink } = require('node:fs/promises');

(async function(path) {
  try {
    await unlink(path);
    console.log(`successfully deleted ${path}`);
  } catch (error) {
    console.error('there was an error:', error.message);
  }
})('/tmp/hello');
09 option to allow writing data at some position past the beginning of the file, allowed values are in the [0,
import { open } from 'node:fs/promises';

const fd = await open('sample.txt');
fd.createReadStream({ start: 90, end: 99 });
13] range. Sửa đổi một tệp thay vì thay thế nó có thể yêu cầu tùy chọn
import * as fs from 'node:fs';const fs = require('node:fs');
10
import * as fs from 'node:fs';const fs = require('node:fs');
11 được đặt thành
import * as fs from 'node:fs';const fs = require('node:fs');
12 thay vì mặc định là
import * as fs from 'node:fs';const fs = require('node:fs');
13.
import { open } from 'node:fs/promises';

const fd = await open('sample.txt');
fd.createReadStream({ start: 90, end: 99 });
17 có thể là bất kỳ một trong số đó được chấp nhận bởi

Nếu

import * as fs from 'node:fs';const fs = require('node:fs');
02 được đặt thành true (hành vi mặc định) trên
import * as fs from 'node:fs';const fs = require('node:fs');
04 hoặc
import * as fs from 'node:fs';const fs = require('node:fs');
17, bộ mô tả tệp sẽ tự động bị đóng. Nếu
import * as fs from 'node:fs';const fs = require('node:fs');
02 là sai, thì bộ mô tả tệp sẽ không bị đóng, ngay cả khi có lỗi. Ứng dụng có trách nhiệm đóng nó và đảm bảo không có rò rỉ bộ mô tả tệp

By default, the stream will emit a

import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
05 event after it has been destroyed. Set the
import * as fs from 'node:fs';const fs = require('node:fs');
00 option to
import * as fs from 'node:fs';const fs = require('node:fs');
01 to change this behavior

import * as fs from 'node:fs';const fs = require('node:fs');
22#
  • Returns. Fulfills with
    import { open } from 'node:fs/promises';
    
    const fd = await open('sample.txt');
    fd.createReadStream({ start: 90, end: 99 });
    6 upon success

Buộc tất cả các hoạt động I/O được xếp hàng hiện tại được liên kết với tệp về trạng thái hoàn thành I/O được đồng bộ hóa của hệ điều hành. Tham khảo tài liệu POSIX

import * as fs from 'node:fs';const fs = require('node:fs');
24 để biết chi tiết

Không giống như

import * as fs from 'node:fs';const fs = require('node:fs');
25, phương pháp này không xóa siêu dữ liệu đã sửa đổi

import * as fs from 'node:fs';const fs = require('node:fs');
26#
import * as fs from 'node:fs';const fs = require('node:fs');
27#
  • import * as fs from 'node:fs';const fs = require('node:fs');
    28. . Một bộ đệm sẽ chứa đầy dữ liệu tệp đã đọc
  • import * as fs from 'node:fs';const fs = require('node:fs');
    29 Vị trí trong bộ đệm để bắt đầu điền
  • import * as fs from 'node:fs';const fs = require('node:fs');
    30 Số byte cần đọc
  • import * as fs from 'node:fs';const fs = require('node:fs');
    31. Vị trí bắt đầu đọc dữ liệu từ tệp. Nếu
    import { open } from 'node:fs/promises';
    
    const fd = await open('sample.txt');
    fd.createReadStream({ start: 90, end: 99 });
    5, dữ liệu sẽ được đọc từ vị trí tệp hiện tại và vị trí sẽ được cập nhật. Nếu
    import * as fs from 'node:fs';const fs = require('node:fs');
    31 là số nguyên, vị trí tệp hiện tại sẽ không thay đổi
  • trả lại. Hoàn thành khi thành công với một đối tượng có hai thuộc tính

Đọc dữ liệu từ tệp và lưu trữ dữ liệu đó trong bộ đệm đã cho

Nếu tệp không được sửa đổi đồng thời, thì kết thúc tệp đạt được khi số byte được đọc bằng 0

import * as fs from 'node:fs';const fs = require('node:fs');
34#

Đã thêm vào. v13. 11. 0, v12. 17. 0

  • import { unlink } from 'node:fs/promises';
    
    try {
      await unlink('/tmp/hello');
      console.log('successfully deleted /tmp/hello');
    } catch (error) {
      console.error('there was an error:', error.message);
    }const { unlink } = require('node:fs/promises');
    
    (async function(path) {
      try {
        await unlink(path);
        console.log(`successfully deleted ${path}`);
      } catch (error) {
        console.error('there was an error:', error.message);
      }
    })('/tmp/hello');
    08
    • import * as fs from 'node:fs';const fs = require('node:fs');
      28. . A buffer that will be filled with the file data read. Default.
      import * as fs from 'node:fs';const fs = require('node:fs');
      37
    • import * as fs from 'node:fs';const fs = require('node:fs');
      29 The location in the buffer at which to start filling. Default.
      import * as fs from 'node:fs';const fs = require('node:fs');
      39
    • import * as fs from 'node:fs';const fs = require('node:fs');
      30 The number of bytes to read. Default.
      import * as fs from 'node:fs';const fs = require('node:fs');
      41
    • import * as fs from 'node:fs';const fs = require('node:fs');
      31 . The location where to begin reading data from the file. Nếu
      import { open } from 'node:fs/promises';
      
      const fd = await open('sample.txt');
      fd.createReadStream({ start: 90, end: 99 });
      5, dữ liệu sẽ được đọc từ vị trí tệp hiện tại và vị trí sẽ được cập nhật. If
      import * as fs from 'node:fs';const fs = require('node:fs');
      31 is an integer, the current file position will remain unchanged. Default.
      import { open } from 'node:fs/promises';
      
      const fd = await open('sample.txt');
      fd.createReadStream({ start: 90, end: 99 });
      5
  • trả lại. Hoàn thành khi thành công với một đối tượng có hai thuộc tính
  • Đọc dữ liệu từ tệp và lưu trữ dữ liệu đó trong bộ đệm đã cho

    Nếu tệp không được sửa đổi đồng thời, thì kết thúc tệp đạt được khi số byte được đọc bằng 0

    import * as fs from 'node:fs';const fs = require('node:fs');
    46#

    Added in. v18. 2. 0, v16. 17. 0

    • import * as fs from 'node:fs';const fs = require('node:fs');
      28. . Một bộ đệm sẽ chứa đầy dữ liệu tệp đã đọc
    • import { unlink } from 'node:fs/promises';
      
      try {
        await unlink('/tmp/hello');
        console.log('successfully deleted /tmp/hello');
      } catch (error) {
        console.error('there was an error:', error.message);
      }const { unlink } = require('node:fs/promises');
      
      (async function(path) {
        try {
          await unlink(path);
          console.log(`successfully deleted ${path}`);
        } catch (error) {
          console.error('there was an error:', error.message);
        }
      })('/tmp/hello');
      08
      • import * as fs from 'node:fs';const fs = require('node:fs');
        29 The location in the buffer at which to start filling. Default.
        import * as fs from 'node:fs';const fs = require('node:fs');
        39
      • import * as fs from 'node:fs';const fs = require('node:fs');
        30 The number of bytes to read. Default.
        import * as fs from 'node:fs';const fs = require('node:fs');
        41
      • import * as fs from 'node:fs';const fs = require('node:fs');
        31 The location where to begin reading data from the file. If
        import { open } from 'node:fs/promises';
        
        const fd = await open('sample.txt');
        fd.createReadStream({ start: 90, end: 99 });
        5, data will be read from the current file position, and the position will be updated. Nếu
        import * as fs from 'node:fs';const fs = require('node:fs');
        31 là số nguyên, vị trí tệp hiện tại sẽ không thay đổi. Default.
        import { open } from 'node:fs/promises';
        
        const fd = await open('sample.txt');
        fd.createReadStream({ start: 90, end: 99 });
        5
    • trả lại. Hoàn thành khi thành công với một đối tượng có hai thuộc tính
    • Đọc dữ liệu từ tệp và lưu trữ dữ liệu đó trong bộ đệm đã cho

      Nếu tệp không được sửa đổi đồng thời, thì kết thúc tệp đạt được khi số byte được đọc bằng 0

      import * as fs from 'node:fs';const fs = require('node:fs');
      57#

      Returns a

      import * as fs from 'node:fs';const fs = require('node:fs');
      58 that may be used to read the files data

      An error will be thrown if this method is called more than once or is called after the

      import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
      02 is closed or closing

      import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
      0

      While the

      import * as fs from 'node:fs';const fs = require('node:fs');
      58 will read the file to completion, it will not close the
      import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
      02 automatically. User code must still call the
      import * as fs from 'node:fs';const fs = require('node:fs');
      62 method

      import * as fs from 'node:fs';const fs = require('node:fs');
      63#
      • import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        08 .
      • Returns. Fulfills upon a successful read with the contents of the file. If no encoding is specified (using
        import * as fs from 'node:fs';const fs = require('node:fs');
        65), the data is returned as a object. Otherwise, the data will be a string
      • Asynchronously reads the entire contents of a file

        If

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        08 is a string, then it specifies the
        import { open } from 'node:fs/promises';
        
        const fd = await open('sample.txt');
        fd.createReadStream({ start: 90, end: 99 });
        17

        The has to support reading

        If one or more

        import * as fs from 'node:fs';const fs = require('node:fs');
        68 calls are made on a file handle and then a
        import * as fs from 'node:fs';const fs = require('node:fs');
        69 call is made, the data will be read from the current position till the end of the file. It doesn't always read from the beginning of the file

        import * as fs from 'node:fs';const fs = require('node:fs');
        70#

        Convenience method to create a

        import * as fs from 'node:fs';const fs = require('node:fs');
        71 interface and stream over the file. See
        import { open } from 'node:fs/promises';
        
        const fd = await open('sample.txt');
        fd.createReadStream({ start: 90, end: 99 });
        16 for the options

        import * as fs from 'node:fs';const fs = require('node:fs');
        0
        import * as fs from 'node:fs';const fs = require('node:fs');
        73#

        Added in. v13. 13. 0, v12. 17. 0

        • import * as fs from 'node:fs';const fs = require('node:fs');
          74 . .
        • import * as fs from 'node:fs';const fs = require('node:fs');
          31 . The offset from the beginning of the file where the data should be read from. If
          import * as fs from 'node:fs';const fs = require('node:fs');
          31 is not a
          import * as fs from 'node:fs';const fs = require('node:fs');
          77, the data will be read from the current position. Mặc định.
          import { open } from 'node:fs/promises';
          
          const fd = await open('sample.txt');
          fd.createReadStream({ start: 90, end: 99 });
          5
        • trả lại. Fulfills upon success an object containing two properties

        Read from a file and write to an array of s

        import * as fs from 'node:fs';const fs = require('node:fs');
        79#

        HistoryVersionChangesv10. 5. 0

        Accepts an additional

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        08 object to specify whether the numeric values returned should be bigint

        v10. 0. 0

        Đã thêm vào. v10. 0. 0

        import * as fs from 'node:fs';const fs = require('node:fs');
        81#
        • Returns. Fulfills with
          import { open } from 'node:fs/promises';
          
          const fd = await open('sample.txt');
          fd.createReadStream({ start: 90, end: 99 });
          6 upon success

        Request that all data for the open file descriptor is flushed to the storage device. The specific implementation is operating system and device specific. Refer to the POSIX

        import * as fs from 'node:fs';const fs = require('node:fs');
        83 documentation for more detail

        import * as fs from 'node:fs';const fs = require('node:fs');
        84#

        Truncates the file

        If the file was larger than

        import * as fs from 'node:fs';const fs = require('node:fs');
        85 bytes, only the first
        import * as fs from 'node:fs';const fs = require('node:fs');
        85 bytes will be retained in the file

        The following example retains only the first four bytes of the file

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        0

        If the file previously was shorter than

        import * as fs from 'node:fs';const fs = require('node:fs');
        85 bytes, it is extended, and the extended part is filled with null bytes (
        import * as fs from 'node:fs';const fs = require('node:fs');
        88)

        If

        import * as fs from 'node:fs';const fs = require('node:fs');
        85 is negative then
        import * as fs from 'node:fs';const fs = require('node:fs');
        39 will be used

        import * as fs from 'node:fs';const fs = require('node:fs');
        91#

        Change the file system timestamps of the object referenced by the then resolves the promise with no arguments upon success

        import * as fs from 'node:fs';const fs = require('node:fs');
        92#

        Lịch sửPhiên bảnChangesv14. 0. 0

        The

        import * as fs from 'node:fs';const fs = require('node:fs');
        28 parameter won't coerce unsupported input to buffers anymore

        v10. 0. 0

        Đã thêm vào. v10. 0. 0

        • import * as fs from 'node:fs';const fs = require('node:fs');
          28 . .
        • import * as fs from 'node:fs';const fs = require('node:fs');
          29 The start position from within
          import * as fs from 'node:fs';const fs = require('node:fs');
          28 where the data to write begins
        • import * as fs from 'node:fs';const fs = require('node:fs');
          30 The number of bytes from
          import * as fs from 'node:fs';const fs = require('node:fs');
          28 to write. Default.
          import * as fs from 'node:fs';const fs = require('node:fs');
          41
        • import * as fs from 'node:fs';const fs = require('node:fs');
          31 . The offset from the beginning of the file where the data from
          import * as fs from 'node:fs';const fs = require('node:fs');
          28 should be written. If
          import * as fs from 'node:fs';const fs = require('node:fs');
          31 is not a
          import * as fs from 'node:fs';const fs = require('node:fs');
          77, the data will be written at the current position. See the POSIX
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          04 documentation for more detail. Default.
          import { open } from 'node:fs/promises';
          
          const fd = await open('sample.txt');
          fd.createReadStream({ start: 90, end: 99 });
          5
        • Returns.

        Write

        import * as fs from 'node:fs';const fs = require('node:fs');
        28 to the file

        The promise is resolved with an object containing two properties

        It is unsafe to use

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        07 multiple times on the same file without waiting for the promise to be resolved (or rejected). For this scenario, use
        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        08

        On Linux, positional writes do not work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        09#

        Added in. v18. 3. 0, v16. 17. 0

        Write

        import * as fs from 'node:fs';const fs = require('node:fs');
        28 to the file

        Similar to the above

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        11 function, this version takes an optional
        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        08 object. If no
        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        08 object is specified, it will default with the above values

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        14#

        Lịch sửPhiên bảnChangesv14. 0. 0

        The

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        15 parameter won't coerce unsupported input to strings anymore

        v10. 0. 0

        Đã thêm vào. v10. 0. 0

        • import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          15
        • import * as fs from 'node:fs';const fs = require('node:fs');
          31 . The offset from the beginning of the file where the data from
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          15 should be written. If
          import * as fs from 'node:fs';const fs = require('node:fs');
          31 is not a
          import * as fs from 'node:fs';const fs = require('node:fs');
          77 the data will be written at the current position. See the POSIX
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          04 documentation for more detail. Default.
          import { open } from 'node:fs/promises';
          
          const fd = await open('sample.txt');
          fd.createReadStream({ start: 90, end: 99 });
          5
        • import { open } from 'node:fs/promises';
          
          const fd = await open('sample.txt');
          fd.createReadStream({ start: 90, end: 99 });
          17 The expected string encoding. Default.
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          24
        • Returns.

        Write

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        15 to the file. If
        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        15 is not a string, the promise is rejected with an error

        The promise is resolved with an object containing two properties

        • import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          27 the number of bytes written
        • import * as fs from 'node:fs';const fs = require('node:fs');
          28 một tham chiếu đến
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          15 bằng văn bản

        It is unsafe to use

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        07 multiple times on the same file without waiting for the promise to be resolved (or rejected). For this scenario, use
        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        08

        On Linux, positional writes do not work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        32#

        HistoryVersionChangesv15. 14. 0, v14. 18. 0

        The

        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
        08 argument supports
        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
        09,
        import * as fs from 'node:fs';const fs = require('node:fs');
        00, and
        import * as fs from 'node:fs';const fs = require('node:fs');
        01

        v14. 0. 0

        The

        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
        08 parameter won't coerce unsupported input to strings anymore

        v10. 0. 0

        Đã thêm vào. v10. 0. 0

        Ghi dữ liệu vào tệp không đồng bộ, thay thế tệp nếu tệp đã tồn tại.

        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
        08 có thể là một chuỗi, một bộ đệm, một hoặc một đối tượng. Lời hứa được giải quyết mà không có tranh luận khi thành công

        If

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        08 is a string, then it specifies the
        import { open } from 'node:fs/promises';
        
        const fd = await open('sample.txt');
        fd.createReadStream({ start: 90, end: 99 });
        17

        Phải hỗ trợ viết

        Sẽ không an toàn khi sử dụng

        import * as fs from 'node:fs';const fs = require('node:fs');
        03 nhiều lần trên cùng một tệp mà không đợi lời hứa được giải quyết (hoặc bị từ chối)

        Nếu một hoặc nhiều lệnh gọi

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        07 được thực hiện trên một bộ xử lý tệp và sau đó một lệnh gọi
        import * as fs from 'node:fs';const fs = require('node:fs');
        03 được thực hiện, dữ liệu sẽ được ghi từ vị trí hiện tại cho đến hết tệp. It doesn't always write from the beginning of the file

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        44#

        Write an array of s to the file

        The promise is resolved with an object containing a two properties

        It is unsafe to call

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        45 multiple times on the same file without waiting for the promise to be resolved (or rejected)

        On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        46#

        Tests a user's permissions for the file or directory specified by

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        47. The
        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        48 argument is an optional integer that specifies the accessibility checks to be performed.
        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        48 should be either the value
        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        50 or a mask consisting of the bitwise OR of any of
        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        51,
        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        52, and
        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        53 (e. g.
        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        54). Check File access constants for possible values of
        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        48

        If the accessibility check is successful, the promise is resolved with no value. If any of the accessibility checks fail, the promise is rejected with an object. The following example checks if the file

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        56 can be read and written by the current process

        import { open } from 'node:fs/promises';
        
        const fd = await open('sample.txt');
        fd.createReadStream({ start: 90, end: 99 });
        1

        Using

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        57 to check for the accessibility of a file before calling
        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
        03 is not recommended. Doing so introduces a race condition, since other processes may change the file's state between the two calls. Instead, user code should open/read/write the file directly and handle the error raised if the file is not accessible

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        59#

        Asynchronously append data to a file, creating the file if it does not yet exist.

        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
        08 can be a string or a

        If

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        08 is a string, then it specifies the
        import { open } from 'node:fs/promises';
        
        const fd = await open('sample.txt');
        fd.createReadStream({ start: 90, end: 99 });
        17

        The

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        48 option only affects the newly created file. See
        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        64 for more details

        The

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        47 may be specified as a that has been opened for appending (using
        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
        03)

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        67#

        Changes the permissions of a file

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        68#

        Changes the ownership of a file

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        69#

        Lịch sửPhiên bảnChangesv14. 0. 0

        Changed

        import * as fs from 'node:fs';const fs = require('node:fs');
        10 argument to
        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        48 and imposed stricter type validation

        v10. 0. 0

        Đã thêm vào. v10. 0. 0

        • import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          72 . . source filename to copy
        • import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          73 . . destination filename of the copy operation
        • import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          48 Optional modifiers that specify the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e. g.
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          75) Default.
          import * as fs from 'node:fs';const fs = require('node:fs');
          39
          • import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            77. The copy operation will fail if
            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            73 already exists
          • import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            79. The copy operation will attempt to create a copy-on-write reflink. If the platform does not support copy-on-write, then a fallback copy mechanism is used
          • import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            80. Thao tác sao chép sẽ cố gắng tạo liên kết giới thiệu sao chép khi ghi. Nếu nền tảng không hỗ trợ sao chép khi ghi, thì thao tác sẽ không thành công
        • Returns. Fulfills with
          import { open } from 'node:fs/promises';
          
          const fd = await open('sample.txt');
          fd.createReadStream({ start: 90, end: 99 });
          6 upon success

        Sao chép không đồng bộ

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        72 sang
        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        73. By default,
        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        73 is overwritten if it already exists

        No guarantees are made about the atomicity of the copy operation. Nếu xảy ra lỗi sau khi tệp đích đã được mở để ghi, một nỗ lực sẽ được thực hiện để xóa đích

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        85#

        HistoryVersionChangesv17. 6. 0, v16. 15. 0

        Accepts an additional

        import { unlink } from 'node:fs/promises';
        
        try {
          await unlink('/tmp/hello');
          console.log('successfully deleted /tmp/hello');
        } catch (error) {
          console.error('there was an error:', error.message);
        }const { unlink } = require('node:fs/promises');
        
        (async function(path) {
          try {
            await unlink(path);
            console.log(`successfully deleted ${path}`);
          } catch (error) {
            console.error('there was an error:', error.message);
          }
        })('/tmp/hello');
        86 option to specify whether to perform path resolution for symlinks

        v16. 7. 0

        Added in. v16. 7. 0

        • import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          72 . source path to copy
        • import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          73 . destination path to copy to
        • import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          08
          • import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            90 dereference symlinks. Default.
            import * as fs from 'node:fs';const fs = require('node:fs');
            01
          • import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            92 when
            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            93 is
            import * as fs from 'node:fs';const fs = require('node:fs');
            01, and the destination exists, throw an error. Default.
            import * as fs from 'node:fs';const fs = require('node:fs');
            01
          • import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            96 Function to filter copied files/directories. Return
            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            97 to copy the item,
            import * as fs from 'node:fs';const fs = require('node:fs');
            01 to ignore it. Can also return a
            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            99 that resolves to
            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            97 or
            import * as fs from 'node:fs';const fs = require('node:fs');
            01 Default.
            import { open } from 'node:fs/promises';
            
            const fd = await open('sample.txt');
            fd.createReadStream({ start: 90, end: 99 });
            6
          • import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            93 overwrite existing file or directory. The copy operation will ignore errors if you set this to false and the destination exists. Use the
            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            92 option to change this behavior. Default.
            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            97
          • import { unlink } from 'node:fs';
            
            unlink('/tmp/hello', (err) => {
              if (err) throw err;
              console.log('successfully deleted /tmp/hello');
            });const { unlink } = require('node:fs');
            
            unlink('/tmp/hello', (err) => {
              if (err) throw err;
              console.log('successfully deleted /tmp/hello');
            });
            06 When
            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            97 timestamps from
            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            72 will be preserved. Default.
            import * as fs from 'node:fs';const fs = require('node:fs');
            01
          • import { unlink } from 'node:fs';
            
            unlink('/tmp/hello', (err) => {
              if (err) throw err;
              console.log('successfully deleted /tmp/hello');
            });const { unlink } = require('node:fs');
            
            unlink('/tmp/hello', (err) => {
              if (err) throw err;
              console.log('successfully deleted /tmp/hello');
            });
            10 copy directories recursively Default.
            import * as fs from 'node:fs';const fs = require('node:fs');
            01
          • import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            86 When
            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            97, path resolution for symlinks will be skipped. Default.
            import * as fs from 'node:fs';const fs = require('node:fs');
            01
        • Returns. Fulfills with
          import { open } from 'node:fs/promises';
          
          const fd = await open('sample.txt');
          fd.createReadStream({ start: 90, end: 99 });
          6 upon success
        • Asynchronously copies the entire directory structure from

          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          72 to
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          73, including subdirectories and files

          When copying a directory to another directory, globs are not supported and behavior is similar to

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          18

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          19#

          Deprecated since. v10. 0. 0

          Changes the permissions on a symbolic link

          This method is only implemented on macOS

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          20#

          HistoryVersionChangesv10. 6. 0

          This API is no longer deprecated

          v10. 0. 0

          Đã thêm vào. v10. 0. 0

          Changes the ownership on a symbolic link

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          21

          Added in. v14. 5. 0, v12. 19. 0

          Changes the access and modification times of a file in the same way as

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          22, with the difference that if the path refers to a symbolic link, then the link is not dereferenced. instead, the timestamps of the symbolic link itself are changed

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          23#

          Creates a new link from the

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          24 to the
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          25. See the POSIX
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          26 documentation for more detail

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          27#

          HistoryVersionChangesv10. 5. 0

          Accepts an additional

          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          08 object to specify whether the numeric values returned should be bigint

          v10. 0. 0

          Đã thêm vào. v10. 0. 0

          Equivalent to

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          29 unless
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          47 refers to a symbolic link, in which case the link itself is stat-ed, not the file that it refers to. Refer to the POSIX
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          31 document for more detail

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          32#

          Asynchronously creates a directory

          Đối số

          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          08 tùy chọn có thể là một số nguyên chỉ định
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          48 (các bit quyền và dính) hoặc một đối tượng có thuộc tính
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          48 và thuộc tính
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          10 cho biết có nên tạo thư mục mẹ hay không. Gọi
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          37 khi
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          47 là một thư mục tồn tại dẫn đến từ chối chỉ khi
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          10 là sai

          import * as fs from 'node:fs';const fs = require('node:fs');
          0

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          40#

          Lịch sửPhiên bảnThay đổiv16. 5. 0, v14. 18. 0

          Tham số

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          41 hiện chấp nhận một chuỗi rỗng

          v10. 0. 0

          Đã thêm vào. v10. 0. 0

          Tạo một thư mục tạm thời duy nhất. Một tên thư mục duy nhất được tạo bằng cách thêm sáu ký tự ngẫu nhiên vào cuối

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          41 được cung cấp. Do sự không nhất quán của nền tảng, hãy tránh sử dụng các ký tự
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          43 trong
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          41. Một số nền tảng, đặc biệt là BSD, có thể trả về nhiều hơn sáu ký tự ngẫu nhiên và thay thế các ký tự
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          43 ở cuối trong
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          41 bằng các ký tự ngẫu nhiên

          Đối số

          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          08 tùy chọn có thể là một chuỗi chỉ định mã hóa hoặc đối tượng có thuộc tính
          import { open } from 'node:fs/promises';
          
          const fd = await open('sample.txt');
          fd.createReadStream({ start: 90, end: 99 });
          17 chỉ định mã hóa ký tự sẽ sử dụng

          import * as fs from 'node:fs';const fs = require('node:fs');
          1

          The

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          49 method will append the six randomly selected characters directly to the
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          41 string. Ví dụ: được cung cấp một thư mục
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          51, nếu mục đích là tạo một thư mục tạm thời trong
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          51, thì ____641 phải kết thúc bằng dấu phân cách đường dẫn dành riêng cho nền tảng (
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          54)

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          55#

          HistoryVersionChangesv11. 1. 0

          The

          import * as fs from 'node:fs';const fs = require('node:fs');
          10 argument is now optional and defaults to
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          57

          v10. 0. 0

          Đã thêm vào. v10. 0. 0

          Opens a

          Refer to the POSIX

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          58 documentation for more detail

          Some characters (

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          59) are reserved under Windows as documented by Naming Files, Paths, and Namespaces. Under NTFS, if the filename contains a colon, Node. js will open a file system stream, as described by this MSDN page

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          60#

          HistoryVersionChangesv13. 1. 0, v12. 16. 0

          The

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          61 option was introduced

          v12. 12. 0

          Added in. v12. 12. 0

          Asynchronously open a directory for iterative scanning. See the POSIX

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          62 documentation for more detail

          Creates an , which contains all further functions for reading from and cleaning up the directory

          The

          import { open } from 'node:fs/promises';
          
          const fd = await open('sample.txt');
          fd.createReadStream({ start: 90, end: 99 });
          17 option sets the encoding for the
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          47 while opening the directory and subsequent read operations

          Example using async iteration

          import * as fs from 'node:fs';const fs = require('node:fs');
          2

          When using the async iterator, the object will be automatically closed after the iterator exits

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          65#

          HistoryVersionChangesv10. 11. 0

          New option

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          66 was added

          v10. 0. 0

          Đã thêm vào. v10. 0. 0

          Reads the contents of a directory

          The optional

          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          08 argument can be a string specifying an encoding, or an object with an
          import { open } from 'node:fs/promises';
          
          const fd = await open('sample.txt');
          fd.createReadStream({ start: 90, end: 99 });
          17 property specifying the character encoding to use for the filenames. If the
          import { open } from 'node:fs/promises';
          
          const fd = await open('sample.txt');
          fd.createReadStream({ start: 90, end: 99 });
          17 is set to
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          70, the filenames returned will be passed as objects

          If

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          71 is set to
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          97, the resolved array will contain objects

          import * as fs from 'node:fs';const fs = require('node:fs');
          3

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          73#

          HistoryVersionChangesv15. 2. 0, v14. 17. 0

          The options argument may include an AbortSignal to abort an ongoing readFile request

          v10. 0. 0

          Đã thêm vào. v10. 0. 0

          Asynchronously reads the entire contents of a file

          If no encoding is specified (using

          import * as fs from 'node:fs';const fs = require('node:fs');
          65), the data is returned as a object. Otherwise, the data will be a string

          If

          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          08 is a string, then it specifies the encoding

          When the

          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          47 is a directory, the behavior of
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          77 is platform-specific. On macOS, Linux, and Windows, the promise will be rejected with an error. On FreeBSD, a representation of the directory's contents will be returned

          An example of reading a

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          78 file located in the same directory of the running code

          import * as fs from 'node:fs';const fs = require('node:fs');
          4

          It is possible to abort an ongoing

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          79 using an . If a request is aborted the promise returned is rejected with an
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          80

          Aborting an ongoing request does not abort individual operating system requests but rather the internal buffering

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          81 performs

          Any specified has to support reading

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          82#

          Reads the contents of the symbolic link referred to by

          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          47. See the POSIX
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          84 documentation for more detail. The promise is resolved with the
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          85 upon success

          The optional

          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          08 argument can be a string specifying an encoding, or an object with an
          import { open } from 'node:fs/promises';
          
          const fd = await open('sample.txt');
          fd.createReadStream({ start: 90, end: 99 });
          17 property specifying the character encoding to use for the link path returned. If the
          import { open } from 'node:fs/promises';
          
          const fd = await open('sample.txt');
          fd.createReadStream({ start: 90, end: 99 });
          17 is set to
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          70, the link path returned will be passed as a object

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          90#

          Determines the actual location of

          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          47 using the same semantics as the
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          92 function

          Only paths that can be converted to UTF8 strings are supported

          The optional

          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          08 argument can be a string specifying an encoding, or an object with an
          import { open } from 'node:fs/promises';
          
          const fd = await open('sample.txt');
          fd.createReadStream({ start: 90, end: 99 });
          17 property specifying the character encoding to use for the path. If the
          import { open } from 'node:fs/promises';
          
          const fd = await open('sample.txt');
          fd.createReadStream({ start: 90, end: 99 });
          17 is set to
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          70, the path returned will be passed as a object

          On Linux, when Node. js is linked against musl libc, the procfs file system must be mounted on

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          97 in order for this function to work. Glibc does not have this restriction

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          98#

          Renames

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          99 to
          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          25

          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          501#

          Lịch sửPhiên bảnThay đổiv16. 0. 0

          Sử dụng

          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          502 trên một tệp
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          47 không còn được phép và dẫn đến lỗi
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          504 trên Windows và lỗi
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          505 trên POSIX

          v16. 0. 0

          Việc sử dụng

          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          502 trên một
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          47 không tồn tại sẽ không còn được phép và dẫn đến lỗi
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          504

          v16. 0. 0

          The

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          10 option is deprecated, using it triggers a deprecation warning

          v14. 14. 0

          The

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          10 option is deprecated, use
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          511 instead

          v13. 3. 0, v12. 16. 0

          The

          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          512 option is renamed to
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          513, and its default is 0. The
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          514 option has been removed, and
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          515 errors use the same retry logic as other errors. The
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          516 option is now supported.
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          517 errors are now retried

          v12. 10. 0

          The

          import { unlink } from 'node:fs';
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });const { unlink } = require('node:fs');
          
          unlink('/tmp/hello', (err) => {
            if (err) throw err;
            console.log('successfully deleted /tmp/hello');
          });
          10,
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          512, and
          import { unlink } from 'node:fs/promises';
          
          try {
            await unlink('/tmp/hello');
            console.log('successfully deleted /tmp/hello');
          } catch (error) {
            console.error('there was an error:', error.message);
          }const { unlink } = require('node:fs/promises');
          
          (async function(path) {
            try {
              await unlink(path);
              console.log(`successfully deleted ${path}`);
            } catch (error) {
              console.error('there was an error:', error.message);
            }
          })('/tmp/hello');
          514 options are now supported

          v10. 0. 0

          Đã thêm vào. v10. 0. 0

          • import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            47 . .
          • import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            08
            • import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              513 If an
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              524,
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              515,
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              517,
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              527, or
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              528 error is encountered, Node. js retries the operation with a linear backoff wait of
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              516 milliseconds longer on each try. This option represents the number of retries. This option is ignored if the
              import { unlink } from 'node:fs';
              
              unlink('/tmp/hello', (err) => {
                if (err) throw err;
                console.log('successfully deleted /tmp/hello');
              });const { unlink } = require('node:fs');
              
              unlink('/tmp/hello', (err) => {
                if (err) throw err;
                console.log('successfully deleted /tmp/hello');
              });
              10 option is not
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              97. Default.
              import * as fs from 'node:fs';const fs = require('node:fs');
              39
            • import { unlink } from 'node:fs';
              
              unlink('/tmp/hello', (err) => {
                if (err) throw err;
                console.log('successfully deleted /tmp/hello');
              });const { unlink } = require('node:fs');
              
              unlink('/tmp/hello', (err) => {
                if (err) throw err;
                console.log('successfully deleted /tmp/hello');
              });
              10 If
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              97, perform a recursive directory removal. In recursive mode, operations are retried on failure. Default.
              import * as fs from 'node:fs';const fs = require('node:fs');
              01. Deprecated
            • import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              516 The amount of time in milliseconds to wait between retries. This option is ignored if the
              import { unlink } from 'node:fs';
              
              unlink('/tmp/hello', (err) => {
                if (err) throw err;
                console.log('successfully deleted /tmp/hello');
              });const { unlink } = require('node:fs');
              
              unlink('/tmp/hello', (err) => {
                if (err) throw err;
                console.log('successfully deleted /tmp/hello');
              });
              10 option is not
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              97. Default.
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              539
          • Returns. Fulfills with
            import { open } from 'node:fs/promises';
            
            const fd = await open('sample.txt');
            fd.createReadStream({ start: 90, end: 99 });
            6 upon success
          • Removes the directory identified by

            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            47

            Using

            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            542 on a file (not a directory) results in the promise being rejected with an
            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            504 error on Windows and an
            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            505 error on POSIX

            To get a behavior similar to the

            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            545 Unix command, use
            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            546 with options
            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            547

            import { unlink } from 'node:fs/promises';
            
            try {
              await unlink('/tmp/hello');
              console.log('successfully deleted /tmp/hello');
            } catch (error) {
              console.error('there was an error:', error.message);
            }const { unlink } = require('node:fs/promises');
            
            (async function(path) {
              try {
                await unlink(path);
                console.log(`successfully deleted ${path}`);
              } catch (error) {
                console.error('there was an error:', error.message);
              }
            })('/tmp/hello');
            548#

            • import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              47 . .
            • import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              08
              • import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                93 When
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                97, exceptions will be ignored if
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                47 does not exist. Default.
                import * as fs from 'node:fs';const fs = require('node:fs');
                01
              • import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                513 If an
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                524,
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                515,
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                517,
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                527, or
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                528 error is encountered, Node. js will retry the operation with a linear backoff wait of
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                516 milliseconds longer on each try. This option represents the number of retries. This option is ignored if the
                import { unlink } from 'node:fs';
                
                unlink('/tmp/hello', (err) => {
                  if (err) throw err;
                  console.log('successfully deleted /tmp/hello');
                });const { unlink } = require('node:fs');
                
                unlink('/tmp/hello', (err) => {
                  if (err) throw err;
                  console.log('successfully deleted /tmp/hello');
                });
                10 option is not
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                97. Default.
                import * as fs from 'node:fs';const fs = require('node:fs');
                39
              • import { unlink } from 'node:fs';
                
                unlink('/tmp/hello', (err) => {
                  if (err) throw err;
                  console.log('successfully deleted /tmp/hello');
                });const { unlink } = require('node:fs');
                
                unlink('/tmp/hello', (err) => {
                  if (err) throw err;
                  console.log('successfully deleted /tmp/hello');
                });
                10 If
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                97, perform a recursive directory removal. In recursive mode operations are retried on failure. Default.
                import * as fs from 'node:fs';const fs = require('node:fs');
                01
              • import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                516 The amount of time in milliseconds to wait between retries. This option is ignored if the
                import { unlink } from 'node:fs';
                
                unlink('/tmp/hello', (err) => {
                  if (err) throw err;
                  console.log('successfully deleted /tmp/hello');
                });const { unlink } = require('node:fs');
                
                unlink('/tmp/hello', (err) => {
                  if (err) throw err;
                  console.log('successfully deleted /tmp/hello');
                });
                10 option is not
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                97. Default.
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                539
            • Returns. Fulfills with
              import { open } from 'node:fs/promises';
              
              const fd = await open('sample.txt');
              fd.createReadStream({ start: 90, end: 99 });
              6 upon success
            • Removes files and directories (modeled on the standard POSIX

              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              573 utility)

              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              574#

              HistoryVersionChangesv10. 5. 0

              Accepts an additional

              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              08 object to specify whether the numeric values returned should be bigint

              v10. 0. 0

              Đã thêm vào. v10. 0. 0

              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              576#

              HistoryVersionChangesv19. 0. 0

              If the

              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              577 argument is
              import { open } from 'node:fs/promises';
              
              const fd = await open('sample.txt');
              fd.createReadStream({ start: 90, end: 99 });
              5 or omitted, Node. js will autodetect
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              579 type and automatically select
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              580 or
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              581

              v10. 0. 0

              Đã thêm vào. v10. 0. 0

              Creates a symbolic link

              The

              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              577 argument is only used on Windows platforms and can be one of
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              583,
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              584, or
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              585. If the
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              577 argument is not a string, Node. js will autodetect
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              579 type and use
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              584 or
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              583. If the
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              579 does not exist,
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              584 will be used. Các điểm giao nhau của Windows yêu cầu đường dẫn đích phải tuyệt đối. Khi sử dụng
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              585, đối số
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              579 sẽ tự động được chuẩn hóa thành đường dẫn tuyệt đối

              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              594

              Truncates (shortens or extends the length) of the content at

              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              47 to
              import * as fs from 'node:fs';const fs = require('node:fs');
              85 bytes

              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              597#

              If

              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              47 refers to a symbolic link, then the link is removed without affecting the file or directory to which that link refers. If the
              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              47 refers to a file path that is not a symbolic link, the file is deleted. See the POSIX
              import { open } from 'node:fs/promises';
              
              const fd = await open('sample.txt');
              fd.createReadStream({ start: 90, end: 99 });
              00 documentation for more detail

              import { open } from 'node:fs/promises';
              
              const fd = await open('sample.txt');
              fd.createReadStream({ start: 90, end: 99 });
              01

              Change the file system timestamps of the object referenced by

              import { unlink } from 'node:fs/promises';
              
              try {
                await unlink('/tmp/hello');
                console.log('successfully deleted /tmp/hello');
              } catch (error) {
                console.error('there was an error:', error.message);
              }const { unlink } = require('node:fs/promises');
              
              (async function(path) {
                try {
                  await unlink(path);
                  console.log(`successfully deleted ${path}`);
                } catch (error) {
                  console.error('there was an error:', error.message);
                }
              })('/tmp/hello');
              47

              The

              import { open } from 'node:fs/promises';
              
              const fd = await open('sample.txt');
              fd.createReadStream({ start: 90, end: 99 });
              03 and
              import { open } from 'node:fs/promises';
              
              const fd = await open('sample.txt');
              fd.createReadStream({ start: 90, end: 99 });
              04 arguments follow these rules

              • Values can be either numbers representing Unix epoch time,
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                05s, or a numeric string like
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                06
              • If the value can not be converted to a number, or is
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                07,
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                08, or
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                09, an
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                10 will be thrown

              import { open } from 'node:fs/promises';
              
              const fd = await open('sample.txt');
              fd.createReadStream({ start: 90, end: 99 });
              11#

              Added in. v15. 9. 0, v14. 18. 0

              • import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                12 . .
              • import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                08 .
                • import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  14 Indicates whether the process should continue to run as long as files are being watched. Default.
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  97
                • import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  10 Indicates whether all subdirectories should be watched, or only the current directory. This applies when a directory is specified, and only on supported platforms (See caveats). Default.
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  01
                • import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  17 Specifies the character encoding to be used for the filename passed to the listener. Default.
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  24
                • import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  20 An used to signal when the watcher should stop
              • Returns. of objects with the properties
              • Returns an async iterator that watches for changes on

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                12, where
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                12 is either a file or a directory

                import * as fs from 'node:fs';const fs = require('node:fs');
                5

                On most platforms,

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                23 is emitted whenever a filename appears or disappears in the directory

                All the caveats for

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                24 also apply to
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                25

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                26#

                HistoryVersionChangesv15. 14. 0, v14. 18. 0

                The

                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                08 argument supports
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                09,
                import * as fs from 'node:fs';const fs = require('node:fs');
                00, and
                import * as fs from 'node:fs';const fs = require('node:fs');
                01

                v15. 2. 0, v14. 17. 0

                The options argument may include an AbortSignal to abort an ongoing writeFile request

                v14. 0. 0

                The

                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                08 parameter won't coerce unsupported input to strings anymore

                v10. 0. 0

                Đã thêm vào. v10. 0. 0

                Asynchronously writes data to a file, replacing the file if it already exists.

                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                08 can be a string, a buffer, an , or an object

                The

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                17 option is ignored if
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                08 is a buffer

                If

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                08 is a string, then it specifies the encoding

                The

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                48 option only affects the newly created file. See
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                64 for more details

                Any specified has to support writing

                It is unsafe to use

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                38 multiple times on the same file without waiting for the promise to be settled

                Similarly to

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                39 -
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                40 is a convenience method that performs multiple
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                41 calls internally to write the buffer passed to it. For performance sensitive code consider using
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                42 or
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                08

                It is possible to use an to cancel an

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                38. Cancelation is "best effort", and some amount of data is likely still to be written

                Aborting an ongoing request does not abort individual operating system requests but rather the internal buffering

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                45 performs

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                46#

                Added in. v18. 4. 0, v16. 17. 0

                Returns an object containing commonly used constants for file system operations. The object is the same as

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                47. See FS constants for more details

                Callback API#

                The callback APIs perform all operations asynchronously, without blocking the event loop, then invoke a callback function upon completion or error

                The callback APIs use the underlying Node. js threadpool to perform file system operations off the event loop thread. These operations are not synchronized or threadsafe. Care must be taken when performing multiple concurrent modifications on the same file or data corruption may occur

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                48#

                HistoryVersionChangesv18. 0. 0

                Passing an invalid callback to the

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                49 argument now throws
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                50 instead of
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                51

                v7. 6. 0

                The

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                47 parameter can be a WHATWG
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                53 object using
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                54 protocol

                v6. 3. 0

                The constants like

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                55, etc which were present directly on
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                56 were moved into
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                47 as a soft deprecation. Thus for Node. js
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                58 use
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                56 to access those constants, or do something like
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                60 to work with all versions

                v0. 11. 15

                Added in. v0. 11. 15

                Tests a user's permissions for the file or directory specified by

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                47. The
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                48 argument is an optional integer that specifies the accessibility checks to be performed.
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                48 should be either the value
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                50 or a mask consisting of the bitwise OR of any of
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                51,
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                52, and
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                53 (e. g.
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                54). Check File access constants for possible values of
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                48

                The final argument,

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                49, is a callback function that is invoked with a possible error argument. If any of the accessibility checks fail, the error argument will be an
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                10 object. The following examples check if
                import { unlink } from 'node:fs';
                
                unlink('/tmp/hello', (err) => {
                  if (err) throw err;
                  console.log('successfully deleted /tmp/hello');
                });const { unlink } = require('node:fs');
                
                unlink('/tmp/hello', (err) => {
                  if (err) throw err;
                  console.log('successfully deleted /tmp/hello');
                });
                78 exists, and if it is readable or writable

                Do not use

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                73 to check for the accessibility of a file before calling
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                64,
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                75, or
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                76. Doing so introduces a race condition, since other processes may change the file's state between the two calls. Instead, user code should open/read/write the file directly and handle the error raised if the file is not accessible

                write (NOT RECOMMENDED)

                import * as fs from 'node:fs';const fs = require('node:fs');
                6

                write (RECOMMENDED)

                import * as fs from 'node:fs';const fs = require('node:fs');
                7

                read (NOT RECOMMENDED)

                import * as fs from 'node:fs';const fs = require('node:fs');
                8

                read (RECOMMENDED)

                import * as fs from 'node:fs';const fs = require('node:fs');
                9

                The "not recommended" examples above check for accessibility and then use the file; the "recommended" examples are better because they use the file directly and handle the error, if any

                Nói chung, chỉ kiểm tra khả năng truy cập của tệp nếu tệp đó sẽ không được sử dụng trực tiếp, ví dụ khi khả năng truy cập tệp là tín hiệu từ một quy trình khác

                On Windows, access-control policies (ACLs) on a directory may limit access to a file or directory. The

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                73 function, however, does not check the ACL and therefore may report that a path is accessible even if the ACL restricts the user from reading or writing to it

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                78#

                HistoryVersionChangesv18. 0. 0

                Passing an invalid callback to the

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                49 argument now throws
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                50 instead of
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                51

                v10. 0. 0

                The

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                49 parameter is no longer optional. Not passing it will throw a
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                83 at runtime

                v7. 0. 0

                The

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                v7. 0. 0

                The passed

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                08 object will never be modified

                v5. 0. 0

                The

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                581 parameter can be a file descriptor now

                v0. 6. 7

                Đã thêm vào. v0. 6. 7

                Asynchronously append data to a file, creating the file if it does not yet exist.

                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                08 can be a string or a

                The

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                48 option only affects the newly created file. See
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                64 for more details

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                0

                If

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                08 is a string, then it specifies the encoding

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                1

                The

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                47 may be specified as a numeric file descriptor that has been opened for appending (using
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                64 or
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                93). The file descriptor will not be closed automatically

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                2

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                94#

                HistoryVersionChangesv18. 0. 0

                Passing an invalid callback to the

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                49 argument now throws
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                50 instead of
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                51

                v10. 0. 0

                The

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                49 parameter is no longer optional. Not passing it will throw a
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                83 at runtime

                v7. 6. 0

                The

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                47 parameter can be a WHATWG
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                53 object using
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                54 protocol

                v7. 0. 0

                The

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                v0. 1. 30

                Added in. v0. 1. 30

                Asynchronously changes the permissions of a file. No arguments other than a possible exception are given to the completion callback

                See the POSIX

                import * as fs from 'node:fs';const fs = require('node:fs');
                07 documentation for more detail

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                3
                File modes#

                The

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                48 argument used in both the
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                006 and
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                007 methods is a numeric bitmask created using a logical OR of the following constants

                ConstantOctalDescription
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                008
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                009read by owner
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                010
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                011write by owner
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                012
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                013execute/search by owner
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                014
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                015read by group
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                016
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                017write by group
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                018
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                019execute/search by group
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                020
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                021read by others
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                022
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                023write by others
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                024
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                025execute/search by others

                An easier method of constructing the

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                48 is to use a sequence of three octal digits (e. g.
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                027). The left-most digit (
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                028 in the example), specifies the permissions for the file owner. The middle digit (
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                029 in the example), specifies permissions for the group. The right-most digit (
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                030 in the example), specifies the permissions for others

                NumberDescription
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                028read, write, and execute
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                029read and write
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                030read and execute
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                034read only
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                035write and execute
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                036write only
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                037execute only
                import * as fs from 'node:fs';const fs = require('node:fs');
                39no permission

                For example, the octal value

                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                039 means

                • The owner may read, write, and execute the file
                • The group may read and write the file
                • Others may read and execute the file

                When using raw numbers where file modes are expected, any value larger than

                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                040 may result in platform-specific behaviors that are not supported to work consistently. Therefore constants like
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                041,
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                042, or
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                043 are not exposed in
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                47

                Caveats. on Windows only the write permission can be changed, and the distinction among the permissions of group, owner, or others is not implemented

                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                045#

                HistoryVersionChangesv18. 0. 0

                Passing an invalid callback to the

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                49 argument now throws
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                50 instead of
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                51

                v10. 0. 0

                The

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                49 parameter is no longer optional. Not passing it will throw a
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                83 at runtime

                v7. 6. 0

                The

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                47 parameter can be a WHATWG
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                53 object using
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                54 protocol

                v7. 0. 0

                The

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                v0. 1. 97

                Added in. v0. 1. 97

                Asynchronously changes owner and group of a file. No arguments other than a possible exception are given to the completion callback

                See the POSIX

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                02 documentation for more detail

                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                056#

                HistoryVersionChangesv18. 0. 0

                Passing an invalid callback to the

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                49 argument now throws
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                50 instead of
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                51

                v15. 9. 0, v14. 17. 0

                A default callback is now used if one is not provided

                v10. 0. 0

                The

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                49 parameter is no longer optional. Not passing it will throw a
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                83 at runtime

                v7. 0. 0

                The

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                v0. 0. 2

                Added in. v0. 0. 2

                Closes the file descriptor. No arguments other than a possible exception are given to the completion callback

                Calling

                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                063 on any file descriptor (
                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                064) that is currently in use through any other
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                56 operation may lead to undefined behavior

                See the POSIX

                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                066 documentation for more detail

                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                067#

                HistoryVersionChangesv18. 0. 0

                Passing an invalid callback to the

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                49 argument now throws
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                50 instead of
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                51

                v14. 0. 0

                Changed

                import * as fs from 'node:fs';const fs = require('node:fs');
                10 argument to
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                48 and imposed stricter type validation

                v8. 5. 0

                Added in. v8. 5. 0

                Asynchronously copies

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                72 to
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                73. By default,
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                73 is overwritten if it already exists. No arguments other than a possible exception are given to the callback function. Node. js makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Node. js will attempt to remove the destination

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                48 is an optional integer that specifies the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e. g.
                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                75)

                • import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  77. The copy operation will fail if
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  73 already exists
                • import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  79. The copy operation will attempt to create a copy-on-write reflink. If the platform does not support copy-on-write, then a fallback copy mechanism is used
                • import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  80. Thao tác sao chép sẽ cố gắng tạo liên kết giới thiệu sao chép khi ghi. Nếu nền tảng không hỗ trợ sao chép khi ghi, thì thao tác sẽ không thành công

                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                082#

                HistoryVersionChangesv18. 0. 0

                Passing an invalid callback to the

                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                49 argument now throws
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                50 instead of
                import { open } from 'node:fs/promises';
                
                const fd = await open('sample.txt');
                fd.createReadStream({ start: 90, end: 99 });
                51

                v17. 6. 0, v16. 15. 0

                Accepts an additional

                import { unlink } from 'node:fs/promises';
                
                try {
                  await unlink('/tmp/hello');
                  console.log('successfully deleted /tmp/hello');
                } catch (error) {
                  console.error('there was an error:', error.message);
                }const { unlink } = require('node:fs/promises');
                
                (async function(path) {
                  try {
                    await unlink(path);
                    console.log(`successfully deleted ${path}`);
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }
                })('/tmp/hello');
                86 option to specify whether to perform path resolution for symlinks

                v16. 7. 0

                Added in. v16. 7. 0

                • import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  72 . source path to copy
                • import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  73 . destination path to copy to
                • import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08
                  • import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    90 dereference symlinks. Default.
                    import * as fs from 'node:fs';const fs = require('node:fs');
                    01
                  • import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    92 when
                    import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    93 is
                    import * as fs from 'node:fs';const fs = require('node:fs');
                    01, and the destination exists, throw an error. Default.
                    import * as fs from 'node:fs';const fs = require('node:fs');
                    01
                  • import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    96 Function to filter copied files/directories. Return
                    import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    97 to copy the item,
                    import * as fs from 'node:fs';const fs = require('node:fs');
                    01 to ignore it. Can also return a
                    import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    99 that resolves to
                    import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    97 or
                    import * as fs from 'node:fs';const fs = require('node:fs');
                    01 Default.
                    import { open } from 'node:fs/promises';
                    
                    const fd = await open('sample.txt');
                    fd.createReadStream({ start: 90, end: 99 });
                    6
                  • import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    93 overwrite existing file or directory. The copy operation will ignore errors if you set this to false and the destination exists. Use the
                    import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    92 option to change this behavior. Default.
                    import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    97
                  • import { unlink } from 'node:fs';
                    
                    unlink('/tmp/hello', (err) => {
                      if (err) throw err;
                      console.log('successfully deleted /tmp/hello');
                    });const { unlink } = require('node:fs');
                    
                    unlink('/tmp/hello', (err) => {
                      if (err) throw err;
                      console.log('successfully deleted /tmp/hello');
                    });
                    06 When
                    import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    97 timestamps from
                    import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    72 will be preserved. Default.
                    import * as fs from 'node:fs';const fs = require('node:fs');
                    01
                  • import { unlink } from 'node:fs';
                    
                    unlink('/tmp/hello', (err) => {
                      if (err) throw err;
                      console.log('successfully deleted /tmp/hello');
                    });const { unlink } = require('node:fs');
                    
                    unlink('/tmp/hello', (err) => {
                      if (err) throw err;
                      console.log('successfully deleted /tmp/hello');
                    });
                    10 copy directories recursively Default.
                    import * as fs from 'node:fs';const fs = require('node:fs');
                    01
                  • import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    86 When
                    import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    97, path resolution for symlinks will be skipped. Default.
                    import * as fs from 'node:fs';const fs = require('node:fs');
                    01
                • import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49
                • Asynchronously copies the entire directory structure from

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  72 to
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  73, including subdirectories and files

                  When copying a directory to another directory, globs are not supported and behavior is similar to

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  18

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  019#

                  HistoryVersionChangesv16. 10. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  56 option does not need
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  11 method if an
                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  064 was provided

                  v16. 10. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  56 option does not need
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  024 method if
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  02 is
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  01

                  v15. 4. 0

                  The

                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  064 option accepts FileHandle arguments

                  v14. 0. 0

                  Change

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  00 default to
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  97

                  v13. 6. 0, v12. 17. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  56 options allow overriding the used
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  56 implementation

                  v12. 10. 0

                  Enable

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  00 option

                  v11. 0. 0

                  Impose new restrictions on

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  09 and
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  10, throwing more appropriate errors in cases when we cannot reasonably handle the input values

                  v7. 6. 0

                  The

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 parameter can be a WHATWG
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  53 object using
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  54 protocol

                  v7. 0. 0

                  The passed

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 object will never be modified

                  v2. 3. 0

                  The passed

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 object can be a string now

                  v0. 1. 31

                  Added in. v0. 1. 31

                  Unlike the 16 KiB default

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  06 for a , the stream returned by this method has a default
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  06 of 64 KiB

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 can include
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  09 and
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  10 values to read a range of bytes from the file instead of the entire file. Both
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  09 and
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  10 are inclusive and start counting at 0, allowed values are in the [0,
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  13] range. If
                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  064 is specified and
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  09 is omitted or
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  6,
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  051 reads sequentially from the current file position. The
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  17 can be any one of those accepted by

                  If

                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  064 is specified,
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  054 will ignore the
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 argument and will use the specified file descriptor. This means that no
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  056 event will be emitted.
                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  064 should be blocking; non-blocking
                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  064s should be passed to

                  If

                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  064 points to a character device that only supports blocking reads (such as keyboard or sound card), read operations do not finish until data is available. This can prevent the process from exiting and the stream from closing naturally

                  By default, the stream will emit a

                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  05 event after it has been destroyed. Set the
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  00 option to
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  01 to change this behavior

                  By providing the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  56 option, it is possible to override the corresponding
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  56 implementations for
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  11,
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  066, and
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  024. When providing the
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  56 option, an override for
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  066 is required. If no
                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  064 is provided, an override for
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  11 is also required. If
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  02 is
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  97, an override for
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  024 is also required

                  If

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  02 is false, then the file descriptor won't be closed, even if there's an error. It is the application's responsibility to close it and make sure there's no file descriptor leak. If
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  02 is set to true (default behavior), on
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  04 or
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  05 the file descriptor will be closed automatically

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  48 đặt chế độ tệp (quyền và bit dính), nhưng chỉ khi tệp được tạo

                  Một ví dụ để đọc 10 byte cuối cùng của tệp dài 100 byte

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  4

                  If

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 is a string, then it specifies the encoding

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  081#

                  HistoryVersionChangesv16. 10. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  56 option does not need
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  11 method if an
                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  064 was provided

                  v16. 10. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  56 option does not need
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  024 method if
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  02 is
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  01

                  v15. 4. 0

                  The

                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  064 option accepts FileHandle arguments

                  v14. 0. 0

                  Change

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  00 default to
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  97

                  v13. 6. 0, v12. 17. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  56 options allow overriding the used
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  56 implementation

                  v12. 10. 0

                  Enable

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  00 option

                  v7. 6. 0

                  The

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 parameter can be a WHATWG
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  53 object using
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  54 protocol

                  v7. 0. 0

                  The passed

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 object will never be modified

                  v5. 5. 0

                  The

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  02 option is supported now

                  v2. 3. 0

                  The passed

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 object can be a string now

                  v0. 1. 31

                  Added in. v0. 1. 31

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 may also include a
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  09 option to allow writing data at some position past the beginning of the file, allowed values are in the [0,
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  13] range. Modifying a file rather than replacing it may require the
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  10 option to be set to
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  12 rather than the default
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  006. The
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  17 can be any one of those accepted by

                  Nếu

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  02 được đặt thành true (hành vi mặc định) trên
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  04 hoặc
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  17, bộ mô tả tệp sẽ tự động bị đóng. Nếu
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  02 là sai, thì bộ mô tả tệp sẽ không bị đóng, ngay cả khi có lỗi. Ứng dụng có trách nhiệm đóng nó và đảm bảo không có rò rỉ bộ mô tả tệp

                  By default, the stream will emit a

                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  05 event after it has been destroyed. Set the
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  00 option to
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  01 to change this behavior

                  By providing the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  56 option it is possible to override the corresponding
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  56 implementations for
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  11,
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  41,
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  019, and
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  024. Overriding
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  021 without
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  45 can reduce performance as some optimizations (
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  023) will be disabled. When providing the
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  56 option, overrides for at least one of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  41 and
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  019 are required. If no
                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  064 option is supplied, an override for
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  11 is also required. If
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  02 is
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  97, an override for
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  024 is also required

                  Like , if

                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  064 is specified, will ignore the
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 argument and will use the specified file descriptor. This means that no
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  056 event will be emitted.
                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  064 should be blocking; non-blocking
                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  064s should be passed to

                  If

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 is a string, then it specifies the encoding

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  038#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v7. 6. 0

                  The

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 parameter can be a WHATWG
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  53 object using
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  54 protocol

                  v1. 0. 0

                  Deprecated since. v1. 0. 0

                  v0. 0. 2

                  Added in. v0. 0. 2

                  Test whether or not the given path exists by checking with the file system. Then call the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument with either true or false

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  5

                  The parameters for this callback are not consistent with other Node. js callbacks. Normally, the first parameter to a Node. js callback is an

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  046 parameter, optionally followed by other parameters. The
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  047 callback has only one boolean parameter. This is one reason
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  73 is recommended instead of
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  047

                  Using

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  047 to check for the existence of a file before calling
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  64,
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  75, or
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  76 is not recommended. Doing so introduces a race condition, since other processes may change the file's state between the two calls. Instead, user code should open/read/write the file directly and handle the error raised if the file does not exist

                  write (NOT RECOMMENDED)

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  6

                  write (RECOMMENDED)

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  7

                  read (NOT RECOMMENDED)

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  8

                  read (RECOMMENDED)

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  9

                  The "not recommended" examples above check for existence and then use the file; the "recommended" examples are better because they use the file directly and handle the error, if any

                  In general, check for the existence of a file only if the file won't be used directly, for example when its existence is a signal from another process

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  054#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v0. 4. 7

                  Added in. v0. 4. 7

                  Sets the permissions on the file. No arguments other than a possible exception are given to the completion callback

                  See the POSIX

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  061 documentation for more detail

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  062#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v0. 4. 7

                  Added in. v0. 4. 7

                  Sets the owner of the file. No arguments other than a possible exception are given to the completion callback

                  See the POSIX

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  069 documentation for more detail

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  070#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v0. 1. 96

                  Added in. v0. 1. 96

                  Forces all currently queued I/O operations associated with the file to the operating system's synchronized I/O completion state. Refer to the POSIX

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  24 documentation for details. No arguments other than a possible exception are given to the completion callback

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  078#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v10. 5. 0

                  Accepts an additional

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 object to specify whether the numeric values returned should be bigint

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v0. 1. 95

                  Added in. v0. 1. 95

                  Invokes the callback with the for the file descriptor

                  See the POSIX

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  086 documentation for more detail

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  087#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v0. 1. 96

                  Added in. v0. 1. 96

                  Request that all data for the open file descriptor is flushed to the storage device. The specific implementation is operating system and device specific. Refer to the POSIX

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  83 documentation for more detail. No arguments other than a possible exception are given to the completion callback

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  095

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v0. 8. 6

                  Added in. v0. 8. 6

                  Truncates the file descriptor. No arguments other than a possible exception are given to the completion callback

                  See the POSIX

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  102 documentation for more detail

                  If the file referred to by the file descriptor was larger than

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  85 bytes, only the first
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  85 bytes will be retained in the file

                  For example, the following program retains only the first four bytes of the file

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  0

                  If the file previously was shorter than

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  85 bytes, it is extended, and the extended part is filled with null bytes (
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  88)

                  If

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  85 is negative then
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  39 will be used

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  109

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v4. 1. 0

                  Numeric strings,

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  07, and
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  08 are now allowed time specifiers

                  v0. 4. 2

                  Added in. v0. 4. 2

                  Change the file system timestamps of the object referenced by the supplied file descriptor. See

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  118

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  119#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v16. 0. 0

                  The error returned may be an

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  123 if more than one error is returned

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v0. 4. 7

                  Deprecated since. v0. 4. 7

                  Changes the permissions on a symbolic link. No arguments other than a possible exception are given to the completion callback

                  This method is only implemented on macOS

                  See the POSIX

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  127 documentation for more detail

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  128#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v10. 6. 0

                  This API is no longer deprecated

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v0. 4. 7

                  Documentation-only deprecation

                  Set the owner of the symbolic link. No arguments other than a possible exception are given to the completion callback

                  See the POSIX

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  135 documentation for more detail

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  136

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v14. 5. 0, v12. 19. 0

                  Added in. v14. 5. 0, v12. 19. 0

                  Changes the access and modification times of a file in the same way as

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  118, with the difference that if the path refers to a symbolic link, then the link is not dereferenced. instead, the timestamps of the symbolic link itself are changed

                  No arguments other than a possible exception are given to the completion callback

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  141#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 6. 0

                  Các tham số

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  24 và
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  25 có thể là các đối tượng WHATWG
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  53 sử dụng giao thức
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  54. Hỗ trợ hiện vẫn đang thử nghiệm

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v0. 1. 31

                  Added in. v0. 1. 31

                  Tạo một liên kết mới từ

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  24 đến
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  25. Xem tài liệu POSIX
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  26 để biết thêm chi tiết. Không có đối số nào khác ngoài một ngoại lệ có thể được đưa ra cho cuộc gọi lại hoàn thành

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  155#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v10. 5. 0

                  Accepts an additional

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 object to specify whether the numeric values returned should be bigint

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 6. 0

                  The

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 parameter can be a WHATWG
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  53 object using
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  54 protocol

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v0. 1. 30

                  Added in. v0. 1. 30

                  Truy xuất liên kết tượng trưng được tham chiếu bởi đường dẫn. Cuộc gọi lại nhận được hai đối số

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  166 trong đó
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  167 là một đối tượng.
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  168 giống hệt với
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  169, ngoại trừ việc nếu
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 là một liên kết tượng trưng, ​​thì chính liên kết đó đã được thống kê, không phải tệp mà nó đề cập đến

                  Xem tài liệu POSIX

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  31 để biết thêm chi tiết

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  172#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v13. 11. 0, v12. 17. 0

                  Ở chế độ

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  10, cuộc gọi lại hiện nhận đường dẫn được tạo đầu tiên làm đối số

                  v10. 12. 0

                  Đối số thứ hai bây giờ có thể là một đối tượng

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 với các thuộc tính
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  10 và
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  48

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 6. 0

                  The

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 parameter can be a WHATWG
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  53 object using
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  54 protocol

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v0. 1. 8

                  Đã thêm vào. v0. 1. 8

                  Asynchronously creates a directory

                  Cuộc gọi lại được đưa ra một ngoại lệ có thể xảy ra và, nếu

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  10 là
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  97, đường dẫn thư mục đầu tiên được tạo,
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  188.
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 vẫn có thể là
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  6 khi
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  10 là
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  97, nếu không có thư mục nào được tạo

                  Đối số

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 tùy chọn có thể là một số nguyên chỉ định
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  48 (các bit quyền và dính) hoặc một đối tượng có thuộc tính
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  48 và thuộc tính
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  10 cho biết có nên tạo thư mục mẹ hay không. Gọi
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  197 khi
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 là một thư mục tồn tại chỉ dẫn đến lỗi khi
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  10 sai

                  On Windows, using

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  197 on the root directory even with recursion will result in an error

                  See the POSIX

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  001 documentation for more details

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  002#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v16. 5. 0, v14. 18. 0

                  Tham số

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  41 hiện chấp nhận một chuỗi rỗng

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v6. 2. 1

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is optional now

                  v5. 10. 0

                  Added in. v5. 10. 0

                  Creates a unique temporary directory

                  Generates six random characters to be appended behind a required

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  41 to create a unique temporary directory. Due to platform inconsistencies, avoid trailing
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  43 characters in
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  41. Some platforms, notably the BSDs, can return more than six random characters, and replace trailing
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  43 characters in
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  41 with random characters

                  The created directory path is passed as a string to the callback's second parameter

                  Đối số

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 tùy chọn có thể là một chuỗi chỉ định mã hóa hoặc đối tượng có thuộc tính
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  17 chỉ định mã hóa ký tự sẽ sử dụng

                  The

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  018 method will append the six randomly selected characters directly to the
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  41 string. For instance, given a directory
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  51, if the intention is to create a temporary directory within
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  51, the
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  41 must end with a trailing platform-specific path separator (
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  54)

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  024#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v11. 1. 0

                  The

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  10 argument is now optional and defaults to
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  57

                  v9. 9. 0

                  The

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  030 and
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  031 flags are supported now

                  v7. 6. 0

                  The

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 parameter can be a WHATWG
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  53 object using
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  54 protocol

                  v0. 0. 2

                  Added in. v0. 0. 2

                  Asynchronous file open. See the POSIX

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  58 documentation for more details

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  48 sets the file mode (permission and sticky bits), but only if the file was created. On Windows, only the write permission can be manipulated; see
                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  006

                  The callback gets two arguments

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  038

                  Some characters (

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  59) are reserved under Windows as documented by Naming Files, Paths, and Namespaces. Under NTFS, if the filename contains a colon, Node. js will open a file system stream, as described by this MSDN page

                  Functions based on

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  64 exhibit this behavior as well.
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  76,
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  75, etc

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  043#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v13. 1. 0, v12. 16. 0

                  The

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  61 option was introduced

                  v12. 12. 0

                  Added in. v12. 12. 0

                  Asynchronously open a directory. See the POSIX

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  62 documentation for more details

                  Creates an , which contains all further functions for reading from and cleaning up the directory

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  17 option sets the encoding for the
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 while opening the directory and subsequent read operations

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  051#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v10. 10. 0

                  The

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  28 parameter can now be any
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  056, or a
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  057

                  v7. 4. 0

                  The

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  28 parameter can now be a
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  059

                  v6. 0. 0

                  The

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  30 parameter can now be
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  39

                  v0. 0. 2

                  Added in. v0. 0. 2

                  • import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                    064
                  • import * as fs from 'node:fs';const fs = require('node:fs');
                    28 . . The buffer that the data will be written to
                  • import * as fs from 'node:fs';const fs = require('node:fs');
                    29 The position in
                    import * as fs from 'node:fs';const fs = require('node:fs');
                    28 to write the data to
                  • import * as fs from 'node:fs';const fs = require('node:fs');
                    30 Số byte cần đọc
                  • import * as fs from 'node:fs';const fs = require('node:fs');
                    31 . . Specifies where to begin reading from in the file. If
                    import * as fs from 'node:fs';const fs = require('node:fs');
                    31 is
                    import { open } from 'node:fs/promises';
                    
                    const fd = await open('sample.txt');
                    fd.createReadStream({ start: 90, end: 99 });
                    5 or
                    import * as fs from 'node:fs';const fs = require('node:fs');
                    070, data will be read from the current file position, and the file position will be updated. If
                    import * as fs from 'node:fs';const fs = require('node:fs');
                    31 is an integer, the file position will be unchanged
                  • import { open } from 'node:fs/promises';
                    
                    const fd = await open('sample.txt');
                    fd.createReadStream({ start: 90, end: 99 });
                    49

                  Read data from the file specified by

                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  064

                  The callback is given the three arguments,

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  074

                  Nếu tệp không được sửa đổi đồng thời, thì kết thúc tệp đạt được khi số byte được đọc bằng 0

                  If this method is invoked as its

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  075ed version, it returns a promise for an
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  076 with
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  077 and
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  28 properties

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  079#

                  HistoryVersionChangesv13. 11. 0, v12. 17. 0

                  Đã thêm vào. v13. 11. 0, v12. 17. 0

                  v13. 11. 0, v12. 17. 0

                  Options object can be passed in to make buffer, offset, length, and position optional

                  Similar to the

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  080 function, this version takes an optional
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 object. If no
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 object is specified, it will default with the above values

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  083#

                  Added in. v18. 2. 0, v16. 17. 0

                  Similar to the

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  080 function, this version takes an optional
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 object. If no
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 object is specified, it will default with the above values

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  087#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v10. 10. 0

                  New option

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  66 was added

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 6. 0

                  The

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 parameter can be a WHATWG
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  53 object using
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  54 protocol

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v6. 0. 0

                  The

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 parameter was added

                  v0. 1. 8

                  Đã thêm vào. v0. 1. 8

                  Reads the contents of a directory. The callback gets two arguments

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  099 where
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  100 is an array of the names of the files in the directory excluding
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  101 and
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  102

                  See the POSIX

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  103 documentation for more details

                  The optional

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 argument can be a string specifying an encoding, or an object with an
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  17 property specifying the character encoding to use for the filenames passed to the callback. If the
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  17 is set to
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  70, the filenames returned will be passed as objects

                  If

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  71 is set to
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  97, the
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  100 array will contain objects

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  111#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v16. 0. 0

                  The error returned may be an

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  123 if more than one error is returned

                  v15. 2. 0, v14. 17. 0

                  The options argument may include an AbortSignal to abort an ongoing readFile request

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 6. 0

                  The

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 parameter can be a WHATWG
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  53 object using
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  54 protocol

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v5. 1. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 will always be called with
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  5 as the
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  124 parameter in case of success

                  v5. 0. 0

                  The

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 parameter can be a file descriptor now

                  v0. 1. 29

                  Added in. v0. 1. 29

                  Asynchronously reads the entire contents of a file

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  1

                  The callback is passed two arguments

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  126, where
                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  08 is the contents of the file

                  If no encoding is specified, then the raw buffer is returned

                  If

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 is a string, then it specifies the encoding

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  2

                  When the path is a directory, the behavior of

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  75 and
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  130 is platform-specific. On macOS, Linux, and Windows, an error will be returned. On FreeBSD, a representation of the directory's contents will be returned

                  It is possible to abort an ongoing request using an

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  131. If a request is aborted the callback is called with an
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  80

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  75 function buffers the entire file. To minimize memory costs, when possible prefer streaming via
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  051

                  Aborting an ongoing request does not abort individual operating system requests but rather the internal buffering

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  81 performs

                  File descriptors#
                  1. Any specified file descriptor has to support reading
                  2. If a file descriptor is specified as the
                    import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    47, it will not be closed automatically
                  3. The reading will begin at the current position. For example, if the file already had
                    import * as fs from 'node:fs';const fs = require('node:fs');
                    137' and six bytes are read with the file descriptor, the call to
                    import { open } from 'node:fs/promises';
                    
                    const fd = await open('sample.txt');
                    fd.createReadStream({ start: 90, end: 99 });
                    75 with the same file descriptor, would give
                    import * as fs from 'node:fs';const fs = require('node:fs');
                    139, rather than
                    import * as fs from 'node:fs';const fs = require('node:fs');
                    140
                  Performance Considerations#

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  75 method asynchronously reads the contents of a file into memory one chunk at a time, allowing the event loop to turn between each chunk. This allows the read operation to have less impact on other activity that may be using the underlying libuv thread pool but means that it will take longer to read a complete file into memory

                  The additional read overhead can vary broadly on different systems and depends on the type of file being read. If the file type is not a regular file (a pipe for instance) and Node. js is unable to determine an actual file size, each read operation will load on 64 KiB of data. For regular files, each read will process 512 KiB of data

                  For applications that require as-fast-as-possible reading of file contents, it is better to use

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  080 directly and for application code to manage reading the full contents of the file itself

                  The Node. js GitHub issue #25741 provides more information and a detailed analysis on the performance of

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  75 for multiple file sizes in different Node. js versions

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  144#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 6. 0

                  The

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 parameter can be a WHATWG
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  53 object using
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  54 protocol

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v0. 1. 31

                  Added in. v0. 1. 31

                  Reads the contents of the symbolic link referred to by

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47. The callback gets two arguments
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  155

                  See the POSIX

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  84 documentation for more details

                  The optional

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 argument can be a string specifying an encoding, or an object with an
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  17 property specifying the character encoding to use for the link path passed to the callback. If the
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  17 is set to
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  70, the link path returned will be passed as a object

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  161#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v13. 13. 0, v12. 17. 0

                  Added in. v13. 13. 0, v12. 17. 0

                  Read from a file specified by

                  import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                  064 and write to an array of
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  166s using
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  167

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  31 is the offset from the beginning of the file from where data should be read. If
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  169, the data will be read from the current position

                  The callback will be given three arguments.

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  046,
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  077, and
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  74.
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  077 is how many bytes were read from the file

                  If this method is invoked as its

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  075ed version, it returns a promise for an
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  076 with
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  077 and
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  74 properties

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  178#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v8. 0. 0

                  Pipe/Socket resolve support was added

                  v7. 6. 0

                  The

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 parameter can be a WHATWG
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  53 object using
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  54 protocol

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v6. 4. 0

                  Calling

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  188 now works again for various edge cases on Windows

                  v6. 0. 0

                  The

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  189 parameter was removed

                  v0. 1. 31

                  Added in. v0. 1. 31

                  Asynchronously computes the canonical pathname by resolving

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  190,
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  191, and symbolic links

                  A canonical pathname is not necessarily unique. Hard links and bind mounts can expose a file system entity through many pathnames

                  This function behaves like

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  192, with some exceptions

                  1. No case conversion is performed on case-insensitive file systems

                  2. The maximum number of symbolic links is platform-independent and generally (much) higher than what the native

                    import * as fs from 'node:fs';const fs = require('node:fs');
                    192 implementation supports

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 gets two arguments
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  195. May use
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  196 to resolve relative paths

                  Only paths that can be converted to UTF8 strings are supported

                  The optional

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 argument can be a string specifying an encoding, or an object with an
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  17 property specifying the character encoding to use for the path passed to the callback. If the
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  17 is set to
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  70, the path returned will be passed as a object

                  If

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 resolves to a socket or a pipe, the function will return a system dependent name for that object

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  202#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v9. 2. 0

                  Added in. v9. 2. 0

                  Asynchronous

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  192

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 gets two arguments
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  195

                  Only paths that can be converted to UTF8 strings are supported

                  The optional

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  08 argument can be a string specifying an encoding, or an object with an
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  17 property specifying the character encoding to use for the path passed to the callback. If the
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  17 is set to
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  70, the path returned will be passed as a object

                  On Linux, when Node. js is linked against musl libc, the procfs file system must be mounted on

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  97 in order for this function to work. Glibc does not have this restriction

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  214#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 6. 0

                  The

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  99 and
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  25 parameters can be WHATWG
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  53 objects using
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  54 protocol. Support is currently still experimental

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v0. 0. 2

                  Added in. v0. 0. 2

                  Asynchronously rename file at

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  99 to the pathname provided as
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  25. In the case that
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  25 already exists, it will be overwritten. If there is a directory at
                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  25, an error will be raised instead. No arguments other than a possible exception are given to the completion callback

                  See also.

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  229

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  3

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  230#

                  HistoryVersionChangesv18. 0. 0

                  Passing an invalid callback to the

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 argument now throws
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  50 instead of
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  51

                  v16. 0. 0

                  Using

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  234 on a
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 that is a file is no longer permitted and results in an
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  504 error on Windows and an
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  505 error on POSIX

                  v16. 0. 0

                  Using

                  import * as fs from 'node:fs';const fs = require('node:fs');
                  234 on a
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 that does not exist is no longer permitted and results in a
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  504 error

                  v16. 0. 0

                  The

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  10 option is deprecated, using it triggers a deprecation warning

                  v14. 14. 0

                  The

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  10 option is deprecated, use
                  import * as fs from 'node:fs';const fs = require('node:fs');
                  243 instead

                  v13. 3. 0, v12. 16. 0

                  The

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  512 option is renamed to
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  513, and its default is 0. The
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  514 option has been removed, and
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  515 errors use the same retry logic as other errors. The
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  516 option is now supported.
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  517 errors are now retried

                  v12. 10. 0

                  The

                  import { unlink } from 'node:fs';
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });const { unlink } = require('node:fs');
                  
                  unlink('/tmp/hello', (err) => {
                    if (err) throw err;
                    console.log('successfully deleted /tmp/hello');
                  });
                  10,
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  512, and
                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  514 options are now supported

                  v10. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will throw a
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  83 at runtime

                  v7. 6. 0

                  The

                  import { unlink } from 'node:fs/promises';
                  
                  try {
                    await unlink('/tmp/hello');
                    console.log('successfully deleted /tmp/hello');
                  } catch (error) {
                    console.error('there was an error:', error.message);
                  }const { unlink } = require('node:fs/promises');
                  
                  (async function(path) {
                    try {
                      await unlink(path);
                      console.log(`successfully deleted ${path}`);
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }
                  })('/tmp/hello');
                  47 parameters can be a WHATWG
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  53 object using
                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  54 protocol

                  v7. 0. 0

                  The

                  import { open } from 'node:fs/promises';
                  
                  const fd = await open('sample.txt');
                  fd.createReadStream({ start: 90, end: 99 });
                  49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                  v0. 0. 2

                  Added in. v0. 0. 2

                  • import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    47 . .
                  • import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    08
                    • import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      513 If an
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      524,
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      515,
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      517,
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      527, or
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      528 error is encountered, Node. js retries the operation with a linear backoff wait of
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      516 milliseconds longer on each try. This option represents the number of retries. This option is ignored if the
                      import { unlink } from 'node:fs';
                      
                      unlink('/tmp/hello', (err) => {
                        if (err) throw err;
                        console.log('successfully deleted /tmp/hello');
                      });const { unlink } = require('node:fs');
                      
                      unlink('/tmp/hello', (err) => {
                        if (err) throw err;
                        console.log('successfully deleted /tmp/hello');
                      });
                      10 option is not
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      97. Default.
                      import * as fs from 'node:fs';const fs = require('node:fs');
                      39
                    • import { unlink } from 'node:fs';
                      
                      unlink('/tmp/hello', (err) => {
                        if (err) throw err;
                        console.log('successfully deleted /tmp/hello');
                      });const { unlink } = require('node:fs');
                      
                      unlink('/tmp/hello', (err) => {
                        if (err) throw err;
                        console.log('successfully deleted /tmp/hello');
                      });
                      10 If
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      97, perform a recursive directory removal. In recursive mode, operations are retried on failure. Default.
                      import * as fs from 'node:fs';const fs = require('node:fs');
                      01. Deprecated
                    • import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      516 The amount of time in milliseconds to wait between retries. This option is ignored if the
                      import { unlink } from 'node:fs';
                      
                      unlink('/tmp/hello', (err) => {
                        if (err) throw err;
                        console.log('successfully deleted /tmp/hello');
                      });const { unlink } = require('node:fs');
                      
                      unlink('/tmp/hello', (err) => {
                        if (err) throw err;
                        console.log('successfully deleted /tmp/hello');
                      });
                      10 option is not
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      97. Default.
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      539
                  • import { open } from 'node:fs/promises';
                    
                    const fd = await open('sample.txt');
                    fd.createReadStream({ start: 90, end: 99 });
                    49
                  • Asynchronous

                    import * as fs from 'node:fs';const fs = require('node:fs');
                    279. No arguments other than a possible exception are given to the completion callback

                    Sử dụng

                    import * as fs from 'node:fs';const fs = require('node:fs');
                    280 trên tệp (không phải thư mục) dẫn đến lỗi
                    import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    504 trên Windows và lỗi
                    import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    505 trên POSIX

                    To get a behavior similar to the

                    import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    545 Unix command, use
                    import * as fs from 'node:fs';const fs = require('node:fs');
                    284 with options
                    import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    547

                    import * as fs from 'node:fs';const fs = require('node:fs');
                    286#

                    HistoryVersionChangesv17. 3. 0, v16. 14. 0

                    The

                    import { unlink } from 'node:fs/promises';
                    
                    try {
                      await unlink('/tmp/hello');
                      console.log('successfully deleted /tmp/hello');
                    } catch (error) {
                      console.error('there was an error:', error.message);
                    }const { unlink } = require('node:fs/promises');
                    
                    (async function(path) {
                      try {
                        await unlink(path);
                        console.log(`successfully deleted ${path}`);
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }
                    })('/tmp/hello');
                    47 parameter can be a WHATWG
                    import { open } from 'node:fs/promises';
                    
                    const fd = await open('sample.txt');
                    fd.createReadStream({ start: 90, end: 99 });
                    53 object using
                    import { open } from 'node:fs/promises';
                    
                    const fd = await open('sample.txt');
                    fd.createReadStream({ start: 90, end: 99 });
                    54 protocol

                    v14. 14. 0

                    Added in. v14. 14. 0

                    • import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      47 . .
                    • import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      08
                      • import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        93 When
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        97, exceptions will be ignored if
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        47 does not exist. Default.
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        01
                      • import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        513 If an
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        524,
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        515,
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        517,
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        527, or
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        528 error is encountered, Node. js will retry the operation with a linear backoff wait of
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        516 milliseconds longer on each try. This option represents the number of retries. This option is ignored if the
                        import { unlink } from 'node:fs';
                        
                        unlink('/tmp/hello', (err) => {
                          if (err) throw err;
                          console.log('successfully deleted /tmp/hello');
                        });const { unlink } = require('node:fs');
                        
                        unlink('/tmp/hello', (err) => {
                          if (err) throw err;
                          console.log('successfully deleted /tmp/hello');
                        });
                        10 option is not
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        97. Default.
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        39
                      • import { unlink } from 'node:fs';
                        
                        unlink('/tmp/hello', (err) => {
                          if (err) throw err;
                          console.log('successfully deleted /tmp/hello');
                        });const { unlink } = require('node:fs');
                        
                        unlink('/tmp/hello', (err) => {
                          if (err) throw err;
                          console.log('successfully deleted /tmp/hello');
                        });
                        10 If
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        97, perform a recursive removal. In recursive mode operations are retried on failure. Default.
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        01
                      • import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        516 The amount of time in milliseconds to wait between retries. This option is ignored if the
                        import { unlink } from 'node:fs';
                        
                        unlink('/tmp/hello', (err) => {
                          if (err) throw err;
                          console.log('successfully deleted /tmp/hello');
                        });const { unlink } = require('node:fs');
                        
                        unlink('/tmp/hello', (err) => {
                          if (err) throw err;
                          console.log('successfully deleted /tmp/hello');
                        });
                        10 option is not
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        97. Default.
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        539
                    • import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      49
                    • Asynchronously removes files and directories (modeled on the standard POSIX

                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      573 utility). No arguments other than a possible exception are given to the completion callback

                      import * as fs from 'node:fs';const fs = require('node:fs');
                      315#

                      HistoryVersionChangesv18. 0. 0

                      Passing an invalid callback to the

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      49 argument now throws
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      50 instead of
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      51

                      v10. 5. 0

                      Accepts an additional

                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      08 object to specify whether the numeric values returned should be bigint

                      v10. 0. 0

                      The

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      49 parameter is no longer optional. Not passing it will throw a
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      83 at runtime

                      v7. 6. 0

                      The

                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      47 parameter can be a WHATWG
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      53 object using
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      54 protocol

                      v7. 0. 0

                      The

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                      v0. 0. 2

                      Added in. v0. 0. 2

                      Asynchronous

                      import * as fs from 'node:fs';const fs = require('node:fs');
                      326. The callback gets two arguments
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      166 where
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      167 is an object

                      In case of an error, the

                      import * as fs from 'node:fs';const fs = require('node:fs');
                      329 will be one of Common System Errors

                      Using

                      import * as fs from 'node:fs';const fs = require('node:fs');
                      330 to check for the existence of a file before calling
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      64,
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      75, or
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      76 is not recommended. Instead, user code should open/read/write the file directly and handle the error raised if the file is not available

                      To check if a file exists without manipulating it afterwards,

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      73 is recommended

                      For example, given the following directory structure

                      import { unlink } from 'node:fs';
                      
                      unlink('/tmp/hello', (err) => {
                        if (err) throw err;
                        console.log('successfully deleted /tmp/hello');
                      });const { unlink } = require('node:fs');
                      
                      unlink('/tmp/hello', (err) => {
                        if (err) throw err;
                        console.log('successfully deleted /tmp/hello');
                      });
                      4

                      Chương trình tiếp theo sẽ kiểm tra số liệu thống kê của các đường dẫn đã cho

                      import { unlink } from 'node:fs';
                      
                      unlink('/tmp/hello', (err) => {
                        if (err) throw err;
                        console.log('successfully deleted /tmp/hello');
                      });const { unlink } = require('node:fs');
                      
                      unlink('/tmp/hello', (err) => {
                        if (err) throw err;
                        console.log('successfully deleted /tmp/hello');
                      });
                      5

                      The resulting output will resemble

                      import { unlink } from 'node:fs';
                      
                      unlink('/tmp/hello', (err) => {
                        if (err) throw err;
                        console.log('successfully deleted /tmp/hello');
                      });const { unlink } = require('node:fs');
                      
                      unlink('/tmp/hello', (err) => {
                        if (err) throw err;
                        console.log('successfully deleted /tmp/hello');
                      });
                      6

                      import * as fs from 'node:fs';const fs = require('node:fs');
                      335#

                      HistoryVersionChangesv18. 0. 0

                      Passing an invalid callback to the

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      49 argument now throws
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      50 instead of
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      51

                      v12. 0. 0

                      If the

                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      577 argument is left undefined, Node will autodetect
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      579 type and automatically select
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      580 or
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      581

                      v7. 6. 0

                      The

                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      579 and
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      47 parameters can be WHATWG
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      53 objects using
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      54 protocol. Support is currently still experimental

                      v0. 1. 31

                      Added in. v0. 1. 31

                      Creates the link called

                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      47 pointing to
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      579. No arguments other than a possible exception are given to the completion callback

                      See the POSIX

                      import * as fs from 'node:fs';const fs = require('node:fs');
                      349 documentation for more details

                      The

                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      577 argument is only available on Windows and ignored on other platforms. It can be set to
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      583,
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      584, or
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      585. If the
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      577 argument is not a string, Node. js will autodetect
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      579 type and use
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      584 or
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      583. If the
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      579 does not exist,
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      584 will be used. Windows junction points require the destination path to be absolute. When using
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      585, the
                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      579 argument will automatically be normalized to absolute path

                      Relative targets are relative to the link's parent directory

                      import { unlink } from 'node:fs';
                      
                      unlink('/tmp/hello', (err) => {
                        if (err) throw err;
                        console.log('successfully deleted /tmp/hello');
                      });const { unlink } = require('node:fs');
                      
                      unlink('/tmp/hello', (err) => {
                        if (err) throw err;
                        console.log('successfully deleted /tmp/hello');
                      });
                      7

                      The above example creates a symbolic link

                      import * as fs from 'node:fs';const fs = require('node:fs');
                      362 which points to
                      import * as fs from 'node:fs';const fs = require('node:fs');
                      363 in the same directory

                      import { unlink } from 'node:fs';
                      
                      unlink('/tmp/hello', (err) => {
                        if (err) throw err;
                        console.log('successfully deleted /tmp/hello');
                      });const { unlink } = require('node:fs');
                      
                      unlink('/tmp/hello', (err) => {
                        if (err) throw err;
                        console.log('successfully deleted /tmp/hello');
                      });
                      8

                      import * as fs from 'node:fs';const fs = require('node:fs');
                      364

                      HistoryVersionChangesv18. 0. 0

                      Passing an invalid callback to the

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      49 argument now throws
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      50 instead of
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      51

                      v16. 0. 0

                      The error returned may be an

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      123 if more than one error is returned

                      v10. 0. 0

                      The

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      49 parameter is no longer optional. Not passing it will throw a
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      83 at runtime

                      v7. 0. 0

                      The

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                      v0. 8. 6

                      Added in. v0. 8. 6

                      Truncates the file. No arguments other than a possible exception are given to the completion callback. A file descriptor can also be passed as the first argument. In this case,

                      import * as fs from 'node:fs';const fs = require('node:fs');
                      372 is called

                      Passing a file descriptor is deprecated and may result in an error being thrown in the future

                      See the POSIX

                      import * as fs from 'node:fs';const fs = require('node:fs');
                      373 documentation for more details

                      import * as fs from 'node:fs';const fs = require('node:fs');
                      374#

                      HistoryVersionChangesv18. 0. 0

                      Passing an invalid callback to the

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      49 argument now throws
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      50 instead of
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      51

                      v10. 0. 0

                      The

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      49 parameter is no longer optional. Not passing it will throw a
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      83 at runtime

                      v7. 6. 0

                      The

                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      47 parameter can be a WHATWG
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      53 object using
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      54 protocol

                      v7. 0. 0

                      The

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                      v0. 0. 2

                      Added in. v0. 0. 2

                      Asynchronously removes a file or symbolic link. Không có đối số nào khác ngoài một ngoại lệ có thể được đưa ra cho cuộc gọi lại hoàn thành

                      import * as fs from 'node:fs';const fs = require('node:fs');
                      384 will not work on a directory, empty or otherwise. To remove a directory, use
                      import * as fs from 'node:fs';const fs = require('node:fs');
                      280

                      See the POSIX

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      00 documentation for more details

                      import * as fs from 'node:fs';const fs = require('node:fs');
                      387#

                      Stop watching for changes on

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      12. If
                      import * as fs from 'node:fs';const fs = require('node:fs');
                      389 is specified, only that particular listener is removed. Otherwise, all listeners are removed, effectively stopping watching of
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      12

                      Gọi

                      import * as fs from 'node:fs';const fs = require('node:fs');
                      391 với tên tệp không được xem là không hoạt động, không phải lỗi

                      Using

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      24 is more efficient than
                      import * as fs from 'node:fs';const fs = require('node:fs');
                      393 and
                      import * as fs from 'node:fs';const fs = require('node:fs');
                      391.
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      24 should be used instead of
                      import * as fs from 'node:fs';const fs = require('node:fs');
                      393 and
                      import * as fs from 'node:fs';const fs = require('node:fs');
                      391 when possible

                      import * as fs from 'node:fs';const fs = require('node:fs');
                      398

                      HistoryVersionChangesv18. 0. 0

                      Passing an invalid callback to the

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      49 argument now throws
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      50 instead of
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      51

                      v10. 0. 0

                      The

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      49 parameter is no longer optional. Not passing it will throw a
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      83 at runtime

                      v8. 0. 0

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      07,
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      08, and
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      09 are no longer valid time specifiers

                      v7. 6. 0

                      The

                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      47 parameter can be a WHATWG
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      53 object using
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      54 protocol

                      v7. 0. 0

                      The

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                      v4. 1. 0

                      Numeric strings,

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      07, and
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      08 are now allowed time specifiers

                      v0. 4. 2

                      Added in. v0. 4. 2

                      Change the file system timestamps of the object referenced by

                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      47

                      The

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      03 and
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      04 arguments follow these rules

                      • Values can be either numbers representing Unix epoch time in seconds,
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        05s, or a numeric string like
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        06
                      • If the value can not be converted to a number, or is
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        07,
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        08, or
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        09, an
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        10 will be thrown

                      import * as fs from 'node:fs';const fs = require('node:fs');
                      422#

                      HistoryVersionChangesv19. 1. 0

                      Added recursive support for Linux, AIX and IBMi

                      v15. 9. 0, v14. 17. 0

                      Added support for closing the watcher with an AbortSignal

                      v7. 6. 0

                      The

                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      12 parameter can be a WHATWG
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      53 object using
                      import { open } from 'node:fs/promises';
                      
                      const fd = await open('sample.txt');
                      fd.createReadStream({ start: 90, end: 99 });
                      54 protocol

                      v7. 0. 0

                      The passed

                      import { unlink } from 'node:fs/promises';
                      
                      try {
                        await unlink('/tmp/hello');
                        console.log('successfully deleted /tmp/hello');
                      } catch (error) {
                        console.error('there was an error:', error.message);
                      }const { unlink } = require('node:fs/promises');
                      
                      (async function(path) {
                        try {
                          await unlink(path);
                          console.log(`successfully deleted ${path}`);
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }
                      })('/tmp/hello');
                      08 object will never be modified

                      v0. 5. 10

                      Added in. v0. 5. 10

                      • import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        12 . .
                      • import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        08 .
                        • import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          14 Indicates whether the process should continue to run as long as files are being watched. Default.
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          97
                        • import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          10 Indicates whether all subdirectories should be watched, or only the current directory. This applies when a directory is specified, and only on supported platforms (See caveats). Default.
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          01
                        • import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          17 Specifies the character encoding to be used for the filename passed to the listener. Default.
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          24
                        • import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          20 allows closing the watcher with an AbortSignal
                      • import * as fs from 'node:fs';const fs = require('node:fs');
                        389 . Default.
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        6
                      • Returns.
                      • Watch for changes on

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        12, where
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        12 is either a file or a directory

                        The second argument is optional. If

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        08 is provided as a string, it specifies the
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        17. Otherwise
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        08 should be passed as an object

                        The listener callback gets two arguments

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        443.
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        444 is either
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        23 or
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        446, and
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        12 is the name of the file which triggered the event

                        On most platforms,

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        23 is emitted whenever a filename appears or disappears in the directory

                        The listener callback is attached to the

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        446 event fired by , but it is not the same thing as the
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        446 value of
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        444

                        If a

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        20 is passed, aborting the corresponding AbortController will close the returned

                        Caveats#

                        The

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        453 API is not 100% consistent across platforms, and is unavailable in some situations

                        On Windows, no events will be emitted if the watched directory is moved or renamed. An

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        528 error is reported when the watched directory is deleted

                        Availability#

                        This feature depends on the underlying operating system providing a way to be notified of filesystem changes

                        • On Linux systems, this uses
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          455
                        • On BSD systems, this uses
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          456
                        • On macOS, this uses
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          456 for files and
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          458 for directories
                        • On SunOS systems (including Solaris and SmartOS), this uses
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          459
                        • On Windows systems, this feature depends on
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          460
                        • On AIX systems, this feature depends on
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          461, which must be enabled
                        • On IBM i systems, this feature is not supported

                        If the underlying functionality is not available for some reason, then

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        24 will not be able to function and may throw an exception. For example, watching files or directories can be unreliable, and in some cases impossible, on network file systems (NFS, SMB, etc) or host file systems when using virtualization software such as Vagrant or Docker

                        It is still possible to use

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        393, which uses stat polling, but this method is slower and less reliable

                        Inodes#

                        On Linux and macOS systems,

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        24 resolves the path to an inode and watches the inode. Nếu đường dẫn đã xem bị xóa và tạo lại, nó sẽ được gán một nút mới. The watch will emit an event for the delete but will continue watching the original inode. Events for the new inode will not be emitted. This is expected behavior

                        AIX files retain the same inode for the lifetime of a file. Saving and closing a watched file on AIX will result in two notifications (one for adding new content, and one for truncation)

                        Filename argument#

                        Providing

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        12 argument in the callback is only supported on Linux, macOS, Windows, and AIX. Even on supported platforms,
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        12 is not always guaranteed to be provided. Therefore, don't assume that
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        12 argument is always provided in the callback, and have some fallback logic if it is
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        5

                        import { unlink } from 'node:fs';
                        
                        unlink('/tmp/hello', (err) => {
                          if (err) throw err;
                          console.log('successfully deleted /tmp/hello');
                        });const { unlink } = require('node:fs');
                        
                        unlink('/tmp/hello', (err) => {
                          if (err) throw err;
                          console.log('successfully deleted /tmp/hello');
                        });
                        9

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        469#

                        HistoryVersionChangesv10. 5. 0

                        The

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        470 option is now supported

                        v7. 6. 0

                        The

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        12 parameter can be a WHATWG
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        53 object using
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        54 protocol

                        v0. 1. 31

                        Added in. v0. 1. 31

                        Watch for changes on

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        12. The callback
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        389 will be called each time the file is accessed

                        Đối số

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        08 có thể được bỏ qua. Nếu được cung cấp, nó phải là một đối tượng. The
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        08 object may contain a boolean named
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        14 that indicates whether the process should continue to run as long as files are being watched. The
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        08 object may specify an
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        480 property indicating how often the target should be polled in milliseconds

                        The

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        389 gets two arguments the current stat object and the previous stat object

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        50

                        These stat objects are instances of

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        482. If the
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        470 option is
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        97, the numeric values in these objects are specified as
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        485s

                        To be notified when the file was modified, not just accessed, it is necessary to compare

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        486 and
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        487

                        When an

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        488 operation results in an
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        504 error, it will invoke the listener once, with all the fields zeroed (or, for dates, the Unix Epoch). If the file is created later on, the listener will be called again, with the latest stat objects. This is a change in functionality since v0. 10

                        Using

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        24 is more efficient than
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        488 and
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        492.
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        453 should be used instead of
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        488 and
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        492 when possible

                        When a file being watched by

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        393 disappears and reappears, then the contents of
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        497 in the second callback event (the file's reappearance) will be the same as the contents of
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        497 in the first callback event (its disappearance)

                        This happens when

                        • the file is deleted, followed by a restore
                        • the file is renamed and then renamed a second time back to its original name

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        499#

                        HistoryVersionChangesv18. 0. 0

                        Passing an invalid callback to the

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        49 argument now throws
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        50 instead of
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        51

                        v14. 0. 0

                        The

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        28 parameter won't coerce unsupported input to strings anymore

                        v10. 10. 0

                        The

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        28 parameter can now be any
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        056 or a
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        057

                        v10. 0. 0

                        The

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        49 parameter is no longer optional. Not passing it will throw a
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        83 at runtime

                        v7. 4. 0

                        The

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        28 parameter can now be a
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        059

                        v7. 2. 0

                        The

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        29 and
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        30 parameters are optional now

                        v7. 0. 0

                        The

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                        v0. 0. 2

                        Added in. v0. 0. 2

                        Write

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        28 to the file specified by
                        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                        064

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        29 determines the part of the buffer to be written, and
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        30 is an integer specifying the number of bytes to write

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        31 refers to the offset from the beginning of the file where this data should be written. If
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        169, the data will be written at the current position. See
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        04

                        The callback will be given three arguments

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        521 where
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        27 specifies how many bytes were written from
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        28

                        If this method is invoked as its

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        075ed version, it returns a promise for an
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        076 with
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        27 and
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        28 properties

                        It is unsafe to use

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        528 multiple times on the same file without waiting for the callback. For this scenario,
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        42 is recommended

                        On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        530#

                        Added in. v18. 3. 0, v16. 17. 0

                        Write

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        28 to the file specified by
                        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                        064

                        Similar to the above

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        533 function, this version takes an optional
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        08 object. If no
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        08 object is specified, it will default with the above values

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        536#

                        HistoryVersionChangesv19. 0. 0

                        Chuyển đến tham số

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        15 một đối tượng có chức năng
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        538 riêng không còn được hỗ trợ

                        v17. 8. 0

                        Passing to the

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        15 parameter an object with an own
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        538 function is deprecated

                        v14. 12. 0

                        The

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        15 parameter will stringify an object with an explicit
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        538 function

                        v14. 0. 0

                        The

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        15 parameter won't coerce unsupported input to strings anymore

                        v10. 0. 0

                        The

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        49 parameter is no longer optional. Not passing it will throw a
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        83 at runtime

                        v7. 2. 0

                        The

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        31 parameter is optional now

                        v7. 0. 0

                        The

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                        v0. 11. 5

                        Added in. v0. 11. 5

                        Write

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        15 to the file specified by
                        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                        064. If
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        15 is not a string, an exception is thrown

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        31 refers to the offset from the beginning of the file where this data should be written. If
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        169 the data will be written at the current position. See
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        04

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        17 is the expected string encoding

                        The callback will receive the arguments

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        555 where
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        556 specifies how many bytes the passed string required to be written. Bytes written is not necessarily the same as string characters written. See
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        557

                        It is unsafe to use

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        528 multiple times on the same file without waiting for the callback. For this scenario,
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        42 is recommended

                        On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file

                        On Windows, if the file descriptor is connected to the console (e. g.

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        560 or
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        561) a string containing non-ASCII characters will not be rendered properly by default, regardless of the encoding used. It is possible to configure the console to render UTF-8 properly by changing the active codepage with the
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        562 command. See the chcp docs for more details

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        563#

                        HistoryVersionChangesv19. 0. 0

                        Chuyển đến tham số

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        15 một đối tượng có chức năng
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        538 riêng không còn được hỗ trợ

                        v18. 0. 0

                        Passing an invalid callback to the

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        49 argument now throws
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        50 instead of
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        51

                        v17. 8. 0

                        Passing to the

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        15 parameter an object with an own
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        538 function is deprecated

                        v16. 0. 0

                        The error returned may be an

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        123 if more than one error is returned

                        v15. 2. 0, v14. 17. 0

                        The options argument may include an AbortSignal to abort an ongoing writeFile request

                        v14. 12. 0

                        The

                        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                        08 parameter will stringify an object with an explicit
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        538 function

                        v14. 0. 0

                        The

                        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                        08 parameter won't coerce unsupported input to strings anymore

                        v10. 10. 0

                        The

                        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                        08 parameter can now be any
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        056 or a
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        057

                        v10. 0. 0

                        The

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        49 parameter is no longer optional. Not passing it will throw a
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        83 at runtime

                        v7. 4. 0

                        The

                        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                        08 parameter can now be a
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        059

                        v7. 0. 0

                        The

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        49 parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013

                        v5. 0. 0

                        The

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        581 parameter can be a file descriptor now

                        v0. 1. 29

                        Added in. v0. 1. 29

                        When

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        581 is a filename, asynchronously writes data to the file, replacing the file if it already exists.
                        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                        08 can be a string or a buffer

                        When

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        581 is a file descriptor, the behavior is similar to calling
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        528 directly (which is recommended). See the notes below on using a file descriptor

                        The

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        17 option is ignored if
                        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                        08 is a buffer

                        The

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        48 option only affects the newly created file. See
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        64 for more details

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        51

                        If

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        08 is a string, then it specifies the encoding

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        52

                        It is unsafe to use

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        76 multiple times on the same file without waiting for the callback. For this scenario,
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        42 is recommended

                        Similarly to

                        import { unlink } from 'node:fs';
                        
                        unlink('/tmp/hello', (err) => {
                          if (err) throw err;
                          console.log('successfully deleted /tmp/hello');
                        });const { unlink } = require('node:fs');
                        
                        unlink('/tmp/hello', (err) => {
                          if (err) throw err;
                          console.log('successfully deleted /tmp/hello');
                        });
                        81 -
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        45 is a convenience method that performs multiple
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        41 calls internally to write the buffer passed to it. For performance sensitive code consider using
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        42

                        It is possible to use an to cancel an

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        76. Cancelation is "best effort", and some amount of data is likely still to be written

                        Aborting an ongoing request does not abort individual operating system requests but rather the internal buffering

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        45 performs

                        Using
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        76 with file descriptors#

                        When

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        581 is a file descriptor, the behavior is almost identical to directly calling
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        528 like

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        53

                        The difference from directly calling

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        528 is that under some unusual conditions,
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        528 might write only part of the buffer and need to be retried to write the remaining data, whereas
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        76 retries until the data is entirely written (or an error occurs)

                        The implications of this are a common source of confusion. In the file descriptor case, the file is not replaced. The data is not necessarily written to the beginning of the file, and the file's original data may remain before and/or after the newly written data

                        For example, if

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        76 is called twice in a row, first to write the string
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        608, then to write the string
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        609, the file would contain
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        610, and might contain some of the file's original data (depending on the size of the original file, and the position of the file descriptor). If a file name had been used instead of a descriptor, the file would be guaranteed to contain only
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        609

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        612#

                        HistoryVersionChangesv18. 0. 0

                        Passing an invalid callback to the

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        49 argument now throws
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        50 instead of
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        51

                        v12. 9. 0

                        Đã thêm vào. v12. 9. 0

                        Write an array of

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        166s to the file specified by
                        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                        064 using
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        45

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        31 is the offset from the beginning of the file where this data should be written. If
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        169, the data will be written at the current position

                        The callback will be given three arguments.

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        046,
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        27, and
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        74.
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        27 is how many bytes were written from
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        74

                        If this method is

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        075ed, it returns a promise for an
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        076 with
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        27 and
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        74 properties

                        It is unsafe to use

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        630 multiple times on the same file without waiting for the callback. For this scenario, use
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        42

                        On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file

                        Synchronous API#

                        The synchronous APIs perform all operations synchronously, blocking the event loop until the operation completes or fails

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        632#

                        HistoryVersionChangesv7. 6. 0

                        The

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        47 parameter can be a WHATWG
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        53 object using
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        54 protocol

                        v0. 11. 15

                        Added in. v0. 11. 15

                        Synchronously tests a user's permissions for the file or directory specified by

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        47. The
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        48 argument is an optional integer that specifies the accessibility checks to be performed.
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        48 should be either the value
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        50 or a mask consisting of the bitwise OR of any of
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        51,
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        52, and
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        53 (e. g.
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        54). Check File access constants for possible values of
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        48

                        Nếu bất kỳ kiểm tra khả năng truy cập nào không thành công, một

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        10 sẽ bị ném. Otherwise, the method will return
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        6

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        54

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        647#

                        Lịch sửPhiên bảnChangesv7. 0. 0

                        The passed

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        08 object will never be modified

                        v5. 0. 0

                        The

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        581 parameter can be a file descriptor now

                        v0. 6. 7

                        Đã thêm vào. v0. 6. 7

                        Synchronously append data to a file, creating the file if it does not yet exist.

                        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                        08 can be a string or a

                        The

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        48 option only affects the newly created file. See
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        64 for more details

                        If

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        08 is a string, then it specifies the encoding

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        55

                        The

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        47 may be specified as a numeric file descriptor that has been opened for appending (using
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        64 or
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        93). The file descriptor will not be closed automatically

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        657#

                        HistoryVersionChangesv7. 6. 0

                        The

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        47 parameter can be a WHATWG
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        53 object using
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        54 protocol

                        v0. 6. 7

                        Đã thêm vào. v0. 6. 7

                        Để biết thông tin chi tiết, hãy xem tài liệu về phiên bản không đồng bộ của API này.

                        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                        006

                        See the POSIX

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        07 documentation for more detail

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        663#

                        HistoryVersionChangesv7. 6. 0

                        The

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        47 parameter can be a WHATWG
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        53 object using
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        54 protocol

                        v0. 1. 97

                        Added in. v0. 1. 97

                        Synchronously changes owner and group of a file. Returns

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        6. This is the synchronous version of
                        import * as fs from 'node:fs';const fs = require('node:fs');
                        668

                        See the POSIX

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        02 documentation for more detail

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        670#

                        Closes the file descriptor. Returns

                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        6

                        Calling

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        672 on any file descriptor (
                        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                        064) that is currently in use through any other
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        56 operation may lead to undefined behavior

                        See the POSIX

                        import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                        066 documentation for more detail

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        676#

                        Lịch sửPhiên bảnChangesv14. 0. 0

                        Changed

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        10 argument to
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        48 and imposed stricter type validation

                        v8. 5. 0

                        Added in. v8. 5. 0

                        Synchronously copies

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        72 to
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        73. By default,
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        73 is overwritten if it already exists. Returns
                        import { open } from 'node:fs/promises';
                        
                        const fd = await open('sample.txt');
                        fd.createReadStream({ start: 90, end: 99 });
                        6. Node. js makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Node. js will attempt to remove the destination

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        48 is an optional integer that specifies the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e. g.
                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        75)

                        • import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          77. The copy operation will fail if
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          73 already exists
                        • import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          79. The copy operation will attempt to create a copy-on-write reflink. If the platform does not support copy-on-write, then a fallback copy mechanism is used
                        • import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          80. Thao tác sao chép sẽ cố gắng tạo liên kết giới thiệu sao chép khi ghi. Nếu nền tảng không hỗ trợ sao chép khi ghi, thì thao tác sẽ không thành công

                        import * as fs from 'node:fs';const fs = require('node:fs');
                        689#

                        HistoryVersionChangesv17. 6. 0, v16. 15. 0

                        Accepts an additional

                        import { unlink } from 'node:fs/promises';
                        
                        try {
                          await unlink('/tmp/hello');
                          console.log('successfully deleted /tmp/hello');
                        } catch (error) {
                          console.error('there was an error:', error.message);
                        }const { unlink } = require('node:fs/promises');
                        
                        (async function(path) {
                          try {
                            await unlink(path);
                            console.log(`successfully deleted ${path}`);
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }
                        })('/tmp/hello');
                        86 option to specify whether to perform path resolution for symlinks

                        v16. 7. 0

                        Added in. v16. 7. 0

                        • import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          72 . source path to copy
                        • import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          73 . destination path to copy to
                        • import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          08
                          • import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            90 dereference symlinks. Default.
                            import * as fs from 'node:fs';const fs = require('node:fs');
                            01
                          • import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            92 when
                            import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            93 is
                            import * as fs from 'node:fs';const fs = require('node:fs');
                            01, and the destination exists, throw an error. Default.
                            import * as fs from 'node:fs';const fs = require('node:fs');
                            01
                          • import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            96 Function to filter copied files/directories. Return
                            import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            97 to copy the item,
                            import * as fs from 'node:fs';const fs = require('node:fs');
                            01 to ignore it. Default.
                            import { open } from 'node:fs/promises';
                            
                            const fd = await open('sample.txt');
                            fd.createReadStream({ start: 90, end: 99 });
                            6
                          • import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            93 overwrite existing file or directory. The copy operation will ignore errors if you set this to false and the destination exists. Use the
                            import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            92 option to change this behavior. Default.
                            import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            97
                          • import { unlink } from 'node:fs';
                            
                            unlink('/tmp/hello', (err) => {
                              if (err) throw err;
                              console.log('successfully deleted /tmp/hello');
                            });const { unlink } = require('node:fs');
                            
                            unlink('/tmp/hello', (err) => {
                              if (err) throw err;
                              console.log('successfully deleted /tmp/hello');
                            });
                            06 When
                            import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            97 timestamps from
                            import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            72 will be preserved. Default.
                            import * as fs from 'node:fs';const fs = require('node:fs');
                            01
                          • import { unlink } from 'node:fs';
                            
                            unlink('/tmp/hello', (err) => {
                              if (err) throw err;
                              console.log('successfully deleted /tmp/hello');
                            });const { unlink } = require('node:fs');
                            
                            unlink('/tmp/hello', (err) => {
                              if (err) throw err;
                              console.log('successfully deleted /tmp/hello');
                            });
                            10 copy directories recursively Default.
                            import * as fs from 'node:fs';const fs = require('node:fs');
                            01
                          • import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            86 When
                            import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            97, path resolution for symlinks will be skipped. Default.
                            import * as fs from 'node:fs';const fs = require('node:fs');
                            01

                          Sao chép đồng bộ toàn bộ cấu trúc thư mục từ

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          72 đến
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          73, bao gồm các thư mục con và tệp

                          When copying a directory to another directory, globs are not supported and behavior is similar to

                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          18

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          719#

                          HistoryVersionChangesv7. 6. 0

                          The

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          47 parameter can be a WHATWG
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          53 object using
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          54 protocol

                          v0. 1. 21

                          Added in. v0. 1. 21

                          Returns

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          97 if the path exists,
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          01 otherwise

                          For detailed information, see the documentation of the asynchronous version of this API.

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          047

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          047 is deprecated, but
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          727 is not. The
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          49 parameter to
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          047 accepts parameters that are inconsistent with other Node. js callbacks.
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          727 does not use a callback

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          56

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          731#

                          Sets the permissions on the file. Returns

                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          6

                          See the POSIX

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          061 documentation for more detail

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          734#

                          Sets the owner of the file. Returns

                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          6

                          See the POSIX

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          069 documentation for more detail

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          737#

                          Forces all currently queued I/O operations associated with the file to the operating system's synchronized I/O completion state. Refer to the POSIX

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          24 documentation for details. Returns
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          6

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          740#

                          HistoryVersionChangesv10. 5. 0

                          Accepts an additional

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          08 object to specify whether the numeric values returned should be bigint

                          v0. 1. 95

                          Added in. v0. 1. 95

                          Retrieves the for the file descriptor

                          See the POSIX

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          086 documentation for more detail

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          743#

                          Request that all data for the open file descriptor is flushed to the storage device. The specific implementation is operating system and device specific. Refer to the POSIX

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          83 documentation for more detail. Returns
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          6

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          746

                          Truncates the file descriptor. Returns

                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          6

                          For detailed information, see the documentation of the asynchronous version of this API.

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          372

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          749

                          HistoryVersionChangesv4. 1. 0

                          Numeric strings,

                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          07, and
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          08 are now allowed time specifiers

                          v0. 4. 2

                          Added in. v0. 4. 2

                          Synchronous version of

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          752. Returns
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          6

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          754#

                          Changes the permissions on a symbolic link. Returns

                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          6

                          This method is only implemented on macOS

                          See the POSIX

                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          127 documentation for more detail

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          757#

                          HistoryVersionChangesv10. 6. 0

                          This API is no longer deprecated

                          v0. 4. 7

                          Documentation-only deprecation

                          Set the owner for the path. Returns

                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          6

                          See the POSIX

                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          135 documentation for more details

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          760

                          Added in. v14. 5. 0, v12. 19. 0

                          Change the file system timestamps of the symbolic link referenced by

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          47. Returns
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          6, or throws an exception when parameters are incorrect or the operation fails. This is the synchronous version of
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          763

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          764

                          HistoryVersionChangesv7. 6. 0

                          Các tham số

                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          24 và
                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          25 có thể là các đối tượng WHATWG
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          53 sử dụng giao thức
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          54. Hỗ trợ hiện vẫn đang thử nghiệm

                          v0. 1. 31

                          Added in. v0. 1. 31

                          Creates a new link from the

                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          24 to the
                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          25. Xem tài liệu POSIX
                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          26 để biết thêm chi tiết. Returns
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          6

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          773#

                          HistoryVersionChangesv15. 3. 0, v14. 17. 0

                          Accepts a

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          774 option to specify whether an exception should be thrown if the entry does not exist

                          v10. 5. 0

                          Accepts an additional

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          08 object to specify whether the numeric values returned should be bigint

                          v7. 6. 0

                          The

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          47 parameter can be a WHATWG
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          53 object using
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          54 protocol

                          v0. 1. 30

                          Added in. v0. 1. 30

                          Retrieves the for the symbolic link referred to by

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          47

                          Xem tài liệu POSIX

                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          31 để biết thêm chi tiết

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          781#

                          HistoryVersionChangesv13. 11. 0, v12. 17. 0

                          In

                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          10 mode, the first created path is returned now

                          v10. 12. 0

                          Đối số thứ hai bây giờ có thể là một đối tượng

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          08 với các thuộc tính
                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          10 và
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          48

                          v7. 6. 0

                          The

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          47 parameter can be a WHATWG
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          53 object using
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          54 protocol

                          v0. 1. 21

                          Added in. v0. 1. 21

                          Synchronously creates a directory. Returns

                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          6, or if
                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          10 is
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          97, the first directory path created. This is the synchronous version of
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          197

                          See the POSIX

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          001 documentation for more details

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          794#

                          Lịch sửPhiên bảnThay đổiv16. 5. 0, v14. 18. 0

                          Tham số

                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          41 hiện chấp nhận một chuỗi rỗng

                          v5. 10. 0

                          Added in. v5. 10. 0

                          Returns the created directory path

                          For detailed information, see the documentation of the asynchronous version of this API.

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          018

                          Đối số

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          08 tùy chọn có thể là một chuỗi chỉ định mã hóa hoặc đối tượng có thuộc tính
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          17 chỉ định mã hóa ký tự sẽ sử dụng

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          799#

                          HistoryVersionChangesv13. 1. 0, v12. 16. 0

                          The

                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          61 option was introduced

                          v12. 12. 0

                          Added in. v12. 12. 0

                          Synchronously open a directory. See

                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          62

                          Creates an , which contains all further functions for reading from and cleaning up the directory

                          The

                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          17 option sets the encoding for the
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          47 while opening the directory and subsequent read operations

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          804#

                          HistoryVersionChangesv11. 1. 0

                          The

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          10 argument is now optional and defaults to
                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          57

                          v9. 9. 0

                          The

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          030 and
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          031 flags are supported now

                          v7. 6. 0

                          The

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          47 parameter can be a WHATWG
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          53 object using
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          54 protocol

                          v0. 1. 21

                          Added in. v0. 1. 21

                          Trả về một số nguyên đại diện cho bộ mô tả tệp

                          For detailed information, see the documentation of the asynchronous version of this API.

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          64

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          813#

                          HistoryVersionChangesv10. 10. 0

                          New option

                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          66 was added

                          v7. 6. 0

                          The

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          47 parameter can be a WHATWG
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          53 object using
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          54 protocol

                          v0. 1. 21

                          Added in. v0. 1. 21

                          Reads the contents of the directory

                          See the POSIX

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          103 documentation for more details

                          The optional

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          08 argument can be a string specifying an encoding, or an object with an
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          17 property specifying the character encoding to use for the filenames returned. Nếu
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          17 được đặt thành
                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          70, tên tệp được trả về sẽ được chuyển dưới dạng đối tượng

                          If

                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          71 is set to
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          97, the result will contain objects

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          825#

                          HistoryVersionChangesv7. 6. 0

                          The

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          47 parameter can be a WHATWG
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          53 object using
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          54 protocol

                          v5. 0. 0

                          The

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          47 parameter can be a file descriptor now

                          v0. 1. 8

                          Đã thêm vào. v0. 1. 8

                          Returns the contents of the

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          47

                          For detailed information, see the documentation of the asynchronous version of this API.

                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          75

                          If the

                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          17 option is specified then this function returns a string. Otherwise it returns a buffer

                          Similar to

                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          75, when the path is a directory, the behavior of
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          130 is platform-specific

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          835

                          HistoryVersionChangesv7. 6. 0

                          The

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          47 parameter can be a WHATWG
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          53 object using
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          54 protocol

                          v0. 1. 31

                          Added in. v0. 1. 31

                          Returns the symbolic link's string value

                          See the POSIX

                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          84 documentation for more details

                          The optional

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          08 argument can be a string specifying an encoding, or an object with an
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          17 property specifying the character encoding to use for the link path returned. If the
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          17 is set to
                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          70, the link path returned will be passed as a object

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          844#

                          HistoryVersionChangesv10. 10. 0

                          The

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          28 parameter can now be any
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          056 or a
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          057

                          v6. 0. 0

                          The

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          30 parameter can now be
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          39

                          v0. 1. 21

                          Added in. v0. 1. 21

                          Returns the number of

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          077

                          For detailed information, see the documentation of the asynchronous version of this API.

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          080

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          852#

                          HistoryVersionChangesv13. 13. 0, v12. 17. 0

                          Added in. v13. 13. 0, v12. 17. 0

                          v13. 13. 0, v12. 17. 0

                          Đối tượng tùy chọn có thể được chuyển vào để tạo độ lệch, độ dài và vị trí tùy chọn

                          Returns the number of

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          077

                          Similar to the above

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          854 function, this version takes an optional
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          08 object. If no
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          08 object is specified, it will default with the above values

                          For detailed information, see the documentation of the asynchronous version of this API.

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          080

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          858#

                          Added in. v13. 13. 0, v12. 17. 0

                          For detailed information, see the documentation of the asynchronous version of this API.

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          859

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          860#

                          HistoryVersionChangesv8. 0. 0

                          Pipe/Socket resolve support was added

                          v7. 6. 0

                          The

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          47 parameter can be a WHATWG
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          53 object using
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          54 protocol

                          v6. 4. 0

                          Calling

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          864 now works again for various edge cases on Windows

                          v6. 0. 0

                          The

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          189 parameter was removed

                          v0. 1. 31

                          Added in. v0. 1. 31

                          Returns the resolved pathname

                          For detailed information, see the documentation of the asynchronous version of this API.

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          866

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          867#

                          Synchronous

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          192

                          Only paths that can be converted to UTF8 strings are supported

                          The optional

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          08 argument can be a string specifying an encoding, or an object with an
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          17 property specifying the character encoding to use for the path returned. If the
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          17 is set to
                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          70, the path returned will be passed as a object

                          On Linux, when Node. js is linked against musl libc, the procfs file system must be mounted on

                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          97 in order for this function to work. Glibc does not have this restriction

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          874#

                          HistoryVersionChangesv7. 6. 0

                          The

                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          99 and
                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          25 parameters can be WHATWG
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          53 objects using
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          54 protocol. Support is currently still experimental

                          v0. 1. 21

                          Added in. v0. 1. 21

                          Renames the file from

                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          99 to
                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          25. Returns
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          6

                          See the POSIX

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          229 documentation for more details

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          883#

                          Lịch sửPhiên bảnThay đổiv16. 0. 0

                          Sử dụng

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          884 trên một tệp
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          47 không còn được phép và dẫn đến lỗi
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          504 trên Windows và lỗi
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          505 trên POSIX

                          v16. 0. 0

                          Việc sử dụng

                          import * as fs from 'node:fs';const fs = require('node:fs');
                          884 trên một
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          47 không tồn tại sẽ không còn được phép và dẫn đến lỗi
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          504

                          v16. 0. 0

                          The

                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          10 option is deprecated, using it triggers a deprecation warning

                          v14. 14. 0

                          The

                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          10 option is deprecated, use
                          import * as fs from 'node:fs';const fs = require('node:fs');
                          893 instead

                          v13. 3. 0, v12. 16. 0

                          The

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          512 option is renamed to
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          513, and its default is 0. The
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          514 option has been removed, and
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          515 errors use the same retry logic as other errors. The
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          516 option is now supported.
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          517 errors are now retried

                          v12. 10. 0

                          The

                          import { unlink } from 'node:fs';
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });const { unlink } = require('node:fs');
                          
                          unlink('/tmp/hello', (err) => {
                            if (err) throw err;
                            console.log('successfully deleted /tmp/hello');
                          });
                          10,
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          512, and
                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          514 options are now supported

                          v7. 6. 0

                          The

                          import { unlink } from 'node:fs/promises';
                          
                          try {
                            await unlink('/tmp/hello');
                            console.log('successfully deleted /tmp/hello');
                          } catch (error) {
                            console.error('there was an error:', error.message);
                          }const { unlink } = require('node:fs/promises');
                          
                          (async function(path) {
                            try {
                              await unlink(path);
                              console.log(`successfully deleted ${path}`);
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }
                          })('/tmp/hello');
                          47 parameters can be a WHATWG
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          53 object using
                          import { open } from 'node:fs/promises';
                          
                          const fd = await open('sample.txt');
                          fd.createReadStream({ start: 90, end: 99 });
                          54 protocol

                          v0. 1. 21

                          Added in. v0. 1. 21

                          • import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            47 . .
                          • import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            08
                            • import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              513 If an
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              524,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              515,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              517,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              527, or
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              528 error is encountered, Node. js retries the operation with a linear backoff wait of
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              516 milliseconds longer on each try. This option represents the number of retries. This option is ignored if the
                              import { unlink } from 'node:fs';
                              
                              unlink('/tmp/hello', (err) => {
                                if (err) throw err;
                                console.log('successfully deleted /tmp/hello');
                              });const { unlink } = require('node:fs');
                              
                              unlink('/tmp/hello', (err) => {
                                if (err) throw err;
                                console.log('successfully deleted /tmp/hello');
                              });
                              10 option is not
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97. Default.
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              39
                            • import { unlink } from 'node:fs';
                              
                              unlink('/tmp/hello', (err) => {
                                if (err) throw err;
                                console.log('successfully deleted /tmp/hello');
                              });const { unlink } = require('node:fs');
                              
                              unlink('/tmp/hello', (err) => {
                                if (err) throw err;
                                console.log('successfully deleted /tmp/hello');
                              });
                              10 If
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97, perform a recursive directory removal. In recursive mode, operations are retried on failure. Default.
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              01. Deprecated
                            • import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              516 The amount of time in milliseconds to wait between retries. This option is ignored if the
                              import { unlink } from 'node:fs';
                              
                              unlink('/tmp/hello', (err) => {
                                if (err) throw err;
                                console.log('successfully deleted /tmp/hello');
                              });const { unlink } = require('node:fs');
                              
                              unlink('/tmp/hello', (err) => {
                                if (err) throw err;
                                console.log('successfully deleted /tmp/hello');
                              });
                              10 option is not
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97. Default.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              539

                            Synchronous

                            import * as fs from 'node:fs';const fs = require('node:fs');
                            279. Returns
                            import { open } from 'node:fs/promises';
                            
                            const fd = await open('sample.txt');
                            fd.createReadStream({ start: 90, end: 99 });
                            6

                            Using

                            import * as fs from 'node:fs';const fs = require('node:fs');
                            927 on a file (not a directory) results in an
                            import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            504 error on Windows and an
                            import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            505 error on POSIX

                            To get a behavior similar to the

                            import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            545 Unix command, use
                            import * as fs from 'node:fs';const fs = require('node:fs');
                            931 with options
                            import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            547

                            import * as fs from 'node:fs';const fs = require('node:fs');
                            933#

                            HistoryVersionChangesv17. 3. 0, v16. 14. 0

                            The

                            import { unlink } from 'node:fs/promises';
                            
                            try {
                              await unlink('/tmp/hello');
                              console.log('successfully deleted /tmp/hello');
                            } catch (error) {
                              console.error('there was an error:', error.message);
                            }const { unlink } = require('node:fs/promises');
                            
                            (async function(path) {
                              try {
                                await unlink(path);
                                console.log(`successfully deleted ${path}`);
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }
                            })('/tmp/hello');
                            47 parameter can be a WHATWG
                            import { open } from 'node:fs/promises';
                            
                            const fd = await open('sample.txt');
                            fd.createReadStream({ start: 90, end: 99 });
                            53 object using
                            import { open } from 'node:fs/promises';
                            
                            const fd = await open('sample.txt');
                            fd.createReadStream({ start: 90, end: 99 });
                            54 protocol

                            v14. 14. 0

                            Added in. v14. 14. 0

                            • import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              47 . .
                            • import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              08
                              • import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                93 When
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                97, exceptions will be ignored if
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                47 does not exist. Default.
                                import * as fs from 'node:fs';const fs = require('node:fs');
                                01
                              • import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                513 If an
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                524,
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                515,
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                517,
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                527, or
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                528 error is encountered, Node. js will retry the operation with a linear backoff wait of
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                516 milliseconds longer on each try. This option represents the number of retries. This option is ignored if the
                                import { unlink } from 'node:fs';
                                
                                unlink('/tmp/hello', (err) => {
                                  if (err) throw err;
                                  console.log('successfully deleted /tmp/hello');
                                });const { unlink } = require('node:fs');
                                
                                unlink('/tmp/hello', (err) => {
                                  if (err) throw err;
                                  console.log('successfully deleted /tmp/hello');
                                });
                                10 option is not
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                97. Default.
                                import * as fs from 'node:fs';const fs = require('node:fs');
                                39
                              • import { unlink } from 'node:fs';
                                
                                unlink('/tmp/hello', (err) => {
                                  if (err) throw err;
                                  console.log('successfully deleted /tmp/hello');
                                });const { unlink } = require('node:fs');
                                
                                unlink('/tmp/hello', (err) => {
                                  if (err) throw err;
                                  console.log('successfully deleted /tmp/hello');
                                });
                                10 If
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                97, perform a recursive directory removal. In recursive mode operations are retried on failure. Default.
                                import * as fs from 'node:fs';const fs = require('node:fs');
                                01
                              • import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                516 The amount of time in milliseconds to wait between retries. This option is ignored if the
                                import { unlink } from 'node:fs';
                                
                                unlink('/tmp/hello', (err) => {
                                  if (err) throw err;
                                  console.log('successfully deleted /tmp/hello');
                                });const { unlink } = require('node:fs');
                                
                                unlink('/tmp/hello', (err) => {
                                  if (err) throw err;
                                  console.log('successfully deleted /tmp/hello');
                                });
                                10 option is not
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                97. Default.
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                539

                              Đồng bộ xóa các tệp và thư mục (được mô hình hóa trên tiện ích POSIX

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              573 tiêu chuẩn). Trả lại
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              6

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              962#

                              HistoryVersionChangesv15. 3. 0, v14. 17. 0

                              Accepts a

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              774 option to specify whether an exception should be thrown if the entry does not exist

                              v10. 5. 0

                              Accepts an additional

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              08 object to specify whether the numeric values returned should be bigint

                              v7. 6. 0

                              The

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              47 parameter can be a WHATWG
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              53 object using
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              54 protocol

                              v0. 1. 21

                              Added in. v0. 1. 21

                              Retrieves the for the path

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              968

                              HistoryVersionChangesv12. 0. 0

                              If the

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              577 argument is left undefined, Node will autodetect
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              579 type and automatically select
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              580 or
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              581

                              v7. 6. 0

                              The

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              579 and
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              47 parameters can be WHATWG
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              53 objects using
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              54 protocol. Support is currently still experimental

                              v0. 1. 31

                              Added in. v0. 1. 31

                              Returns

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              6

                              Để biết thông tin chi tiết, hãy xem tài liệu về phiên bản không đồng bộ của API này.

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              978

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              979

                              Cắt bớt tập tin. Trả lại

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              6. Một bộ mô tả tệp cũng có thể được chuyển làm đối số đầu tiên. Trong trường hợp này,
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              981 được gọi là

                              Passing a file descriptor is deprecated and may result in an error being thrown in the future

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              982

                              HistoryVersionChangesv7. 6. 0

                              The

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              47 parameter can be a WHATWG
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              53 object using
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              54 protocol

                              v0. 1. 21

                              Added in. v0. 1. 21

                              Đồng bộ

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              00. Trả lại
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              6

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              988

                              HistoryVersionChangesv8. 0. 0

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              07,
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              08, and
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              09 are no longer valid time specifiers

                              v7. 6. 0

                              The

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              47 parameter can be a WHATWG
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              53 object using
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              54 protocol

                              v4. 1. 0

                              Numeric strings,

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              07, and
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              08 are now allowed time specifiers

                              v0. 4. 2

                              Added in. v0. 4. 2

                              Returns

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              6

                              Để biết thông tin chi tiết, hãy xem tài liệu về phiên bản không đồng bộ của API này.

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              118

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              999#

                              HistoryVersionChangesv19. 0. 0

                              Chuyển đến tham số

                              import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                              08 một đối tượng có chức năng
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              538 riêng không còn được hỗ trợ

                              v17. 8. 0

                              Chuyển đến tham số

                              import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                              08 một đối tượng có hàm riêng
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              538 không được dùng nữa

                              v14. 12. 0

                              The

                              import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                              08 parameter will stringify an object with an explicit
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              538 function

                              v14. 0. 0

                              The

                              import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                              08 parameter won't coerce unsupported input to strings anymore

                              v10. 10. 0

                              The

                              import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                              08 parameter can now be any
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              056 or a
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              057

                              v7. 4. 0

                              The

                              import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                              08 parameter can now be a
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              059

                              v5. 0. 0

                              The

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              581 parameter can be a file descriptor now

                              v0. 1. 29

                              Added in. v0. 1. 29

                              Returns

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              6

                              The

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              48 option only affects the newly created file. See
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              64 for more details

                              Để biết thông tin chi tiết, hãy xem tài liệu về phiên bản không đồng bộ của API này.

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              76

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              017#

                              Lịch sửPhiên bảnChangesv14. 0. 0

                              The

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              28 parameter won't coerce unsupported input to strings anymore

                              v10. 10. 0

                              The

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              28 parameter can now be any
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              056 or a
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              057

                              v7. 4. 0

                              The

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              28 parameter can now be a
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              059

                              v7. 2. 0

                              The

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              29 and
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              30 parameters are optional now

                              v0. 1. 21

                              Added in. v0. 1. 21

                              Để biết thông tin chi tiết, hãy xem tài liệu về phiên bản không đồng bộ của API này.

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              026

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              027#

                              Added in. v18. 3. 0, v16. 17. 0

                              Để biết thông tin chi tiết, hãy xem tài liệu về phiên bản không đồng bộ của API này.

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              026

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              029#

                              Lịch sửPhiên bảnChangesv14. 0. 0

                              The

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              15 parameter won't coerce unsupported input to strings anymore

                              v7. 2. 0

                              The

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              31 parameter is optional now

                              v0. 11. 5

                              Added in. v0. 11. 5

                              Để biết thông tin chi tiết, hãy xem tài liệu về phiên bản không đồng bộ của API này.

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              032

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              033#

                              Để biết thông tin chi tiết, hãy xem tài liệu về phiên bản không đồng bộ của API này.

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              630

                              Những vật thông thường#

                              Các đối tượng chung được chia sẻ bởi tất cả các biến thể API hệ thống tệp (lời hứa, gọi lại và đồng bộ)

                              Class.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              035#

                              Một lớp đại diện cho một luồng thư mục

                              Được tạo bởi

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              036,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              037 hoặc
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              038

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              2

                              When using the async iterator, the object will be automatically closed after the iterator exits

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              039#

                              Đóng xử lý tài nguyên cơ bản của thư mục một cách không đồng bộ. Các lần đọc tiếp theo sẽ dẫn đến lỗi

                              Một lời hứa được trả lại sẽ được giải quyết sau khi tài nguyên đã bị đóng

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              040#

                              HistoryVersionChangesv18. 0. 0

                              Passing an invalid callback to the

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              49 argument now throws
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              50 instead of
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              51

                              v12. 12. 0

                              Added in. v12. 12. 0

                              Đóng xử lý tài nguyên cơ bản của thư mục một cách không đồng bộ. Các lần đọc tiếp theo sẽ dẫn đến lỗi

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              49 sẽ được gọi sau khi xử lý tài nguyên đã bị đóng

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              045#

                              Đóng đồng bộ xử lý tài nguyên cơ bản của thư mục. Các lần đọc tiếp theo sẽ dẫn đến lỗi

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              046#

                              Đường dẫn chỉ đọc của thư mục này như được cung cấp cho

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              036,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              037 hoặc
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              038

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              050#

                              Đọc không đồng bộ mục nhập thư mục tiếp theo qua

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              103 dưới dạng

                              Một lời hứa được trả lại sẽ được giải quyết bằng , hoặc

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              5 nếu không còn mục nhập thư mục nào để đọc

                              Các mục nhập thư mục được hàm này trả về không theo thứ tự cụ thể như được cung cấp bởi các cơ chế thư mục cơ bản của hệ điều hành. Các mục được thêm hoặc xóa trong khi lặp qua thư mục có thể không được đưa vào kết quả lặp

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              053#

                              Đọc không đồng bộ mục nhập thư mục tiếp theo qua

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              103 dưới dạng

                              Sau khi đọc xong,

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              49 sẽ được gọi với dấu , hoặc
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              5 nếu không còn mục nhập thư mục nào để đọc

                              Các mục nhập thư mục được hàm này trả về không theo thứ tự cụ thể như được cung cấp bởi các cơ chế thư mục cơ bản của hệ điều hành. Các mục được thêm hoặc xóa trong khi lặp qua thư mục có thể không được đưa vào kết quả lặp

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              057#

                              Đọc đồng bộ mục nhập thư mục tiếp theo dưới dạng. Xem tài liệu POSIX

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              103 để biết thêm chi tiết

                              Nếu không còn mục nào trong thư mục để đọc, thì sẽ trả về

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              5

                              Các mục nhập thư mục được hàm này trả về không theo thứ tự cụ thể như được cung cấp bởi các cơ chế thư mục cơ bản của hệ điều hành. Các mục được thêm hoặc xóa trong khi lặp qua thư mục có thể không được đưa vào kết quả lặp

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              060#

                              Lặp lại không đồng bộ trên thư mục cho đến khi tất cả các mục đã được đọc. Tham khảo tài liệu POSIX

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              103 để biết thêm chi tiết

                              Các mục được trả về bởi trình vòng lặp không đồng bộ luôn là một. Trường hợp

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              5 từ
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              050 được xử lý nội bộ

                              Xem ví dụ

                              Các mục nhập thư mục được trình vòng lặp này trả về không theo thứ tự cụ thể như được cung cấp bởi các cơ chế thư mục cơ bản của hệ điều hành. Các mục được thêm hoặc xóa trong khi lặp qua thư mục có thể không được đưa vào kết quả lặp

                              Lớp.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              064#

                              Một đại diện của một mục nhập thư mục, có thể là một tệp hoặc thư mục con trong thư mục, được trả về bằng cách đọc từ một. Mục nhập thư mục là sự kết hợp của các cặp tên tệp và loại tệp

                              Ngoài ra, khi

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              065 hoặc
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              066 được gọi với tùy chọn
                              import { unlink } from 'node:fs';
                              
                              unlink('/tmp/hello', (err) => {
                                if (err) throw err;
                                console.log('successfully deleted /tmp/hello');
                              });const { unlink } = require('node:fs');
                              
                              unlink('/tmp/hello', (err) => {
                                if (err) throw err;
                                console.log('successfully deleted /tmp/hello');
                              });
                              66 được đặt thành
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97, mảng kết quả được lấp đầy bằng các đối tượng, thay vì các chuỗi hoặc s

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              069#

                              Trả về

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97 nếu đối tượng mô tả một thiết bị khối

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              071#

                              Trả về

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97 nếu đối tượng mô tả một thiết bị ký tự

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              073#

                              Trả về

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97 nếu đối tượng mô tả thư mục hệ thống tệp

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              075#

                              Trả về

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97 nếu đối tượng mô tả ống nhập trước xuất trước (FIFO)

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              077#

                              Trả về

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97 nếu đối tượng mô tả một tệp thông thường

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              079#

                              Trả về

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97 nếu đối tượng mô tả một ổ cắm

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              081#

                              Trả về

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97 nếu đối tượng mô tả một liên kết tượng trưng

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              083#

                              Tên tệp mà đối tượng này đề cập đến. Loại giá trị này được xác định bởi

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              65 được chuyển đến
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              065 hoặc
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              066

                              Lớp.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              087#

                              Gọi thành công phương thức

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              24 sẽ trả về một đối tượng mới

                              Tất cả các đối tượng phát ra sự kiện

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              446 bất cứ khi nào một tệp đã xem cụ thể được sửa đổi

                              Biến cố.
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              446#
                              • import * as fs from 'node:fs';const fs = require('node:fs');
                                444 Loại sự kiện thay đổi đã xảy ra
                              • import { open } from 'node:fs/promises';
                                
                                const fd = await open('sample.txt');
                                fd.createReadStream({ start: 90, end: 99 });
                                12. Tên tệp đã thay đổi (nếu có/có liên quan)

                              Phát ra khi có gì đó thay đổi trong thư mục hoặc tệp đã xem. Xem thêm chi tiết trong

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              24

                              Đối số

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              12 có thể không được cung cấp tùy thuộc vào sự hỗ trợ của hệ điều hành. Nếu
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              12 được cung cấp, thì nó sẽ được cung cấp dưới dạng nếu
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              24 được gọi với tùy chọn
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              17 của nó được đặt thành
                              import { unlink } from 'node:fs';
                              
                              unlink('/tmp/hello', (err) => {
                                if (err) throw err;
                                console.log('successfully deleted /tmp/hello');
                              });const { unlink } = require('node:fs');
                              
                              unlink('/tmp/hello', (err) => {
                                if (err) throw err;
                                console.log('successfully deleted /tmp/hello');
                              });
                              70, nếu không thì
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              12 sẽ là chuỗi UTF-8

                              Event.
                              import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                              05#

                              Được phát ra khi người xem ngừng theo dõi các thay đổi. Đối tượng đã đóng không còn sử dụng được trong trình xử lý sự kiện

                              Biến cố.
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              04#

                              Xuất hiện khi xảy ra lỗi trong khi xem tệp. Đối tượng bị lỗi không còn sử dụng được trong trình xử lý sự kiện

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              102#

                              Ngừng theo dõi các thay đổi trên đã cho. Sau khi dừng, đối tượng không còn sử dụng được nữa

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              103#

                              Đã thêm vào. v14. 3. 0, v12. 20. 0

                              Khi được gọi, yêu cầu Node. vòng lặp sự kiện js không thoát miễn là nó đang hoạt động. Gọi

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              103 nhiều lần sẽ không có hiệu lực

                              Theo mặc định, tất cả các đối tượng đều được "ref'ed", khiến việc gọi

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              103 thông thường không cần thiết trừ khi trước đó đã gọi
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              106

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              106#

                              Đã thêm vào. v14. 3. 0, v12. 20. 0

                              Khi được gọi, đối tượng hoạt động sẽ không yêu cầu Nút. vòng lặp sự kiện js để duy trì hoạt động. Nếu không có hoạt động nào khác giữ cho vòng lặp sự kiện chạy, quy trình có thể thoát trước khi lệnh gọi lại của đối tượng được gọi. Gọi

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              106 nhiều lần sẽ không có hiệu lực

                              Lớp.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              109#

                              Đã thêm vào. v14. 3. 0, v12. 20. 0

                              Một cuộc gọi thành công đến phương thức

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              393 sẽ trả về một đối tượng mới

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              103#

                              Đã thêm vào. v14. 3. 0, v12. 20. 0

                              Khi được gọi, yêu cầu Node. vòng lặp sự kiện js không thoát miễn là nó đang hoạt động. Gọi

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              103 nhiều lần sẽ không có hiệu lực

                              Theo mặc định, tất cả các đối tượng đều được "ref'ed", khiến việc gọi

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              103 thông thường không cần thiết trừ khi trước đó đã gọi
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              106

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              106#

                              Đã thêm vào. v14. 3. 0, v12. 20. 0

                              Khi được gọi, đối tượng hoạt động sẽ không yêu cầu Nút. vòng lặp sự kiện js để duy trì hoạt động. Nếu không có hoạt động nào khác giữ cho vòng lặp sự kiện chạy, quy trình có thể thoát trước khi lệnh gọi lại của đối tượng được gọi. Gọi

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              106 nhiều lần sẽ không có hiệu lực

                              Lớp.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              117#

                              Các phiên bản của được tạo và trả về bằng cách sử dụng hàm

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              051

                              Event.
                              import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                              05#

                              Được phát ra khi bộ mô tả tệp cơ bản của đã bị đóng

                              Biến cố.
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              056#

                              Được phát ra khi bộ mô tả tệp của đã được mở

                              Biến cố.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              121#

                              Phát ra khi đã sẵn sàng để được sử dụng

                              Cháy ngay sau

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              056

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              123#

                              Số lượng byte đã được đọc cho đến nay

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              124#

                              Đường dẫn đến tệp mà luồng đang đọc từ đó như được chỉ định trong đối số đầu tiên của

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              051. Nếu
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              47 được truyền dưới dạng chuỗi, thì
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              124 sẽ là chuỗi. Nếu
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              47 được chuyển thành a , thì
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              124 sẽ là a. Nếu chỉ định
                              import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                              064 thì
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              124 sẽ là
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              6

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              133#

                              Đã thêm vào. v11. 2. 0, v10. 16. 0

                              Thuộc tính này là

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97 nếu tệp cơ bản chưa được mở, tôi. e. trước khi sự kiện
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              121 được phát ra

                              Lớp.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              136#

                              Lịch sửPhiên bảnChangesv8. 1. 0

                              Đã thêm lần dưới dạng số

                              v0. 1. 21

                              Added in. v0. 1. 21

                              Một đối tượng cung cấp thông tin về một tập tin

                              Các đối tượng được trả về từ

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              330,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              138,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              139 và các đối tượng đồng bộ của chúng thuộc loại này. Nếu
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              470 trong
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              08 được truyền cho các phương thức đó là đúng, thì các giá trị số sẽ là
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              470 thay vì
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              77 và đối tượng sẽ chứa các thuộc tính chính xác nano giây bổ sung có hậu tố là
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              144

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              58

                              Phiên bản

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              470

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              59
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              146#

                              Trả về

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97 nếu đối tượng mô tả một thiết bị khối

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              148#

                              Trả về

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97 nếu đối tượng mô tả một thiết bị ký tự

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              150#

                              Trả về

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97 nếu đối tượng mô tả thư mục hệ thống tệp

                              Nếu đối tượng được lấy từ

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              138, phương thức này sẽ luôn trả về
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              01. Điều này là do
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              138 trả về thông tin về chính liên kết tượng trưng chứ không phải đường dẫn mà nó giải quyết

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              155#

                              Trả về

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97 nếu đối tượng mô tả ống nhập trước xuất trước (FIFO)

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              157#

                              Trả về

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97 nếu đối tượng mô tả một tệp thông thường

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              159#

                              Trả về

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97 nếu đối tượng mô tả một ổ cắm

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              161#

                              Trả về

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97 nếu đối tượng mô tả một liên kết tượng trưng

                              Phương pháp này chỉ hợp lệ khi sử dụng

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              138

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              164#

                              Số nhận dạng của thiết bị chứa tệp

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              165#

                              Số "Inode" cụ thể của hệ thống tệp cho tệp

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              166#

                              Một trường bit mô tả loại tệp và chế độ

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              167#

                              Số lượng liên kết cứng tồn tại cho tệp

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              168#

                              Định danh người dùng dạng số của người dùng sở hữu tệp (POSIX)

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              169#

                              Số nhận dạng nhóm số của nhóm sở hữu tệp (POSIX)

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              170#

                              Số nhận dạng thiết bị số nếu tệp đại diện cho một thiết bị

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              171#

                              Kích thước của tệp tính bằng byte

                              Nếu hệ thống tệp cơ bản không hỗ trợ nhận kích thước của tệp, điều này sẽ là

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              39

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              173#

                              Kích thước khối hệ thống tệp cho các thao tác i/o

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              174#

                              Số khối được phân bổ cho tệp này

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              175

                              Dấu thời gian cho biết lần cuối cùng tệp này được truy cập được biểu thị bằng mili giây kể từ Kỷ nguyên POSIX

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              176

                              Dấu thời gian cho biết lần cuối cùng tệp này được sửa đổi được biểu thị bằng mili giây kể từ Kỷ nguyên POSIX

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              177

                              Dấu thời gian cho biết lần cuối cùng trạng thái tệp được thay đổi được biểu thị bằng mili giây kể từ Kỷ nguyên POSIX

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              178

                              Dấu thời gian cho biết thời gian tạo tệp này được biểu thị bằng mili giây kể từ Kỷ nguyên POSIX

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              179

                              Chỉ xuất hiện khi

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              180 được chuyển vào phương thức tạo đối tượng. Dấu thời gian cho biết lần cuối cùng tệp này được truy cập được biểu thị bằng nano giây kể từ Kỷ nguyên POSIX

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              181

                              Chỉ xuất hiện khi

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              180 được chuyển vào phương thức tạo đối tượng. Dấu thời gian cho biết lần cuối cùng tệp này được sửa đổi được biểu thị bằng nano giây kể từ Kỷ nguyên POSIX

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              183

                              Chỉ xuất hiện khi

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              180 được chuyển vào phương thức tạo đối tượng. Dấu thời gian cho biết lần cuối cùng trạng thái tệp được thay đổi được biểu thị bằng nano giây kể từ Kỷ nguyên POSIX

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              185

                              Chỉ xuất hiện khi

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              180 được chuyển vào phương thức tạo đối tượng. Dấu thời gian cho biết thời gian tạo tệp này được biểu thị bằng nano giây kể từ Kỷ nguyên POSIX

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              187

                              Dấu thời gian cho biết lần cuối tệp này được truy cập

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              188

                              Dấu thời gian cho biết lần cuối cùng tệp này được sửa đổi

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              189

                              Dấu thời gian cho biết lần cuối trạng thái tệp được thay đổi

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              190

                              Dấu thời gian cho biết thời gian tạo tệp này

                              Giá trị thời gian thống kê

                              Các thuộc tính

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              191,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              192,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              193,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              194 là các giá trị số chứa thời gian tương ứng tính bằng mili giây. Độ chính xác của chúng là nền tảng cụ thể. Khi
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              180 được truyền vào phương thức tạo đối tượng, các thuộc tính sẽ là bigint, nếu không chúng sẽ là số

                              Các thuộc tính

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              196,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              197,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              198,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              199 là các bigint giữ thời gian tương ứng tính bằng nano giây. Chúng chỉ xuất hiện khi
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              180 được truyền vào phương thức tạo đối tượng. Độ chính xác của chúng là nền tảng cụ thể

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              03,
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              04,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              203 và
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              204 là các đại diện thay thế đối tượng của
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              05 trong các thời điểm khác nhau. Giá trị
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              05 và số không được kết nối. Việc chỉ định một giá trị số mới hoặc thay đổi giá trị
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              05 sẽ không được phản ánh trong biểu diễn thay thế tương ứng

                              Thời gian trong đối tượng stat có ngữ nghĩa sau

                              • import { open } from 'node:fs/promises';
                                
                                const fd = await open('sample.txt');
                                fd.createReadStream({ start: 90, end: 99 });
                                03 "Thời gian truy cập". Thời gian khi dữ liệu tệp được truy cập lần cuối. Được thay đổi bởi các cuộc gọi hệ thống
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                209,
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                210 và
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                211
                              • import { open } from 'node:fs/promises';
                                
                                const fd = await open('sample.txt');
                                fd.createReadStream({ start: 90, end: 99 });
                                04 "Thời gian sửa đổi". Thời gian khi dữ liệu tệp được sửa đổi lần cuối. Được thay đổi bởi các cuộc gọi hệ thống
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                209,
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                210 và
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                215
                              • import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                203 "Thay đổi thời gian". Thời gian khi trạng thái tệp được thay đổi lần cuối (sửa đổi dữ liệu inode). Được thay đổi bởi các cuộc gọi hệ thống
                                import * as fs from 'node:fs';const fs = require('node:fs');
                                07,
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                02,
                                import { unlink } from 'node:fs';
                                
                                unlink('/tmp/hello', (err) => {
                                  if (err) throw err;
                                  console.log('successfully deleted /tmp/hello');
                                });const { unlink } = require('node:fs');
                                
                                unlink('/tmp/hello', (err) => {
                                  if (err) throw err;
                                  console.log('successfully deleted /tmp/hello');
                                });
                                26,
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                209,
                                import * as fs from 'node:fs';const fs = require('node:fs');
                                229,
                                import { open } from 'node:fs/promises';
                                
                                const fd = await open('sample.txt');
                                fd.createReadStream({ start: 90, end: 99 });
                                00,
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                210,
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                211 và
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                215
                              • import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                204 "Giờ sinh". Thời gian tạo tập tin. Đặt một lần khi tệp được tạo. Trên các hệ thống tệp không có sẵn thời gian sinh, thay vào đó, trường này có thể chứa
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                203 hoặc
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                228 (tức là dấu thời gian kỷ nguyên Unix
                                import * as fs from 'node:fs';const fs = require('node:fs');
                                39). This value may be greater than
                                import { open } from 'node:fs/promises';
                                
                                const fd = await open('sample.txt');
                                fd.createReadStream({ start: 90, end: 99 });
                                03 or
                                import { open } from 'node:fs/promises';
                                
                                const fd = await open('sample.txt');
                                fd.createReadStream({ start: 90, end: 99 });
                                04 in this case. Trên Darwin và các biến thể FreeBSD khác, cũng được đặt nếu
                                import { open } from 'node:fs/promises';
                                
                                const fd = await open('sample.txt');
                                fd.createReadStream({ start: 90, end: 99 });
                                03 được đặt rõ ràng thành giá trị sớm hơn giá trị hiện tại của
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                204 bằng lệnh gọi hệ thống
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                210

                              Trước nút. js 0. 12,

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              203 giữ
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              204 trên hệ thống Windows. kể từ 0. 12,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              203 không phải là "thời gian sáng tạo" và trên các hệ thống Unix, nó chưa bao giờ là

                              Lớp.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              238#

                              Các phiên bản của được tạo và trả về bằng cách sử dụng hàm

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              42

                              Event.
                              import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                              05#

                              Được phát ra khi bộ mô tả tệp cơ bản của đã bị đóng

                              Biến cố.
                              import * as fs from 'node:fs';const fs = require('node:fs');
                              056#

                              Phát ra khi tệp của được mở

                              Biến cố.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              121#

                              Phát ra khi đã sẵn sàng để được sử dụng

                              Cháy ngay sau

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              056

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              244#

                              Số lượng byte được ghi cho đến nay. Không bao gồm dữ liệu vẫn đang xếp hàng để ghi

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              245#

                              Đóng

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              246. Tùy chọn chấp nhận một cuộc gọi lại sẽ được thực hiện sau khi đóng
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              246

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              248#

                              Đường dẫn đến tệp mà luồng đang ghi vào như được chỉ định trong đối số đầu tiên của

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              42. Nếu
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              47 được truyền dưới dạng chuỗi, thì
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              248 sẽ là chuỗi. If
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              47 is passed as a , then
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              248 will be a

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              254#

                              Thuộc tính này là

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              97 nếu tệp cơ bản chưa được mở, tôi. e. trước khi sự kiện
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              121 được phát ra

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              47#

                              Trả về một đối tượng chứa các hằng số thường được sử dụng cho các hoạt động của hệ thống tệp

                              Hằng số FS#

                              Các hằng số sau đây được xuất bởi

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              47 và
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              46

                              Không phải mọi hằng số sẽ có sẵn trên mọi hệ điều hành; . Đối với các ứng dụng di động, nên kiểm tra sự hiện diện của chúng trước khi sử dụng

                              Để sử dụng nhiều hơn một hằng số, hãy sử dụng toán tử bitwise OR

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              260

                              Thí dụ

                              Hằng số truy cập tệp #

                              Các hằng số sau được dùng làm tham số

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              48 được truyền cho
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              57,
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              73 và
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              264

                              ConstantDescription
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              265Cờ cho biết tệp hiển thị với quy trình gọi. Điều này hữu ích để xác định xem một tệp có tồn tại hay không, nhưng không nói gì về quyền của
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              266. Mặc định nếu không có chế độ nào được chỉ định.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              267Cờ cho biết quá trình gọi có thể đọc tệp.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              268Cờ chỉ ra rằng tệp có thể được ghi bởi quá trình gọi.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              269Cờ chỉ ra rằng tệp có thể được thực thi bởi quy trình gọi. Điều này không ảnh hưởng đến Windows (sẽ hoạt động như
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              50)

                              The definitions are also available on Windows

                              Hằng số sao chép tệp #

                              Các hằng số sau đây được dùng với

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              271

                              ConstantDescription
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              272Nếu có, thao tác sao chép sẽ không thành công với lỗi nếu đường dẫn đích đã tồn tại.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              273Nếu có, thao tác sao chép sẽ cố gắng tạo liên kết giới thiệu sao chép khi ghi. Nếu nền tảng cơ bản không hỗ trợ sao chép khi ghi, thì cơ chế sao chép dự phòng sẽ được sử dụng.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              274Nếu có, thao tác sao chép sẽ cố gắng tạo liên kết giới thiệu sao chép khi ghi. Nếu nền tảng cơ bản không hỗ trợ sao chép khi ghi, thì thao tác sẽ không thành công với lỗi

                              The definitions are also available on Windows

                              Các hằng số mở tệp#

                              Các hằng số sau đây được dùng với

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              64

                              ConstantDescription
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              276Cờ cho biết mở tệp để truy cập chỉ đọc.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              277Flag indicating to open a file for write-only access.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              278Cờ cho biết mở tệp để truy cập đọc-ghi.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              279Cờ cho biết để tạo tệp nếu nó chưa tồn tại.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              280Cờ cho biết rằng việc mở tệp sẽ không thành công nếu cờ
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              279 được đặt và tệp đã tồn tại.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              282Cờ chỉ ra rằng nếu đường dẫn xác định một thiết bị đầu cuối, thì việc mở đường dẫn sẽ không khiến thiết bị đầu cuối đó trở thành thiết bị đầu cuối kiểm soát quy trình (nếu quy trình chưa có).
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              283Cờ chỉ ra rằng nếu tệp tồn tại và là tệp thông thường và tệp được mở thành công để truy cập ghi, thì độ dài của tệp sẽ bị cắt ngắn thành 0.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              284Cờ cho biết dữ liệu sẽ được thêm vào cuối tệp.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              285Cờ chỉ ra rằng việc mở sẽ thất bại nếu đường dẫn không phải là một thư mục.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              286Cờ cho biết quyền truy cập đọc vào hệ thống tệp sẽ không còn dẫn đến cập nhật thông tin
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              03 được liên kết với tệp. Cờ này chỉ khả dụng trên hệ điều hành Linux.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              288Cờ chỉ ra rằng việc mở sẽ thất bại nếu đường dẫn là một liên kết tượng trưng.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              289Cờ cho biết tệp được mở cho I/O được đồng bộ hóa với các thao tác ghi đang chờ tính toàn vẹn của tệp.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              290Cờ cho biết tệp được mở cho I/O được đồng bộ hóa với các thao tác ghi đang chờ tính toàn vẹn của dữ liệu.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              291Cờ chỉ ra để mở chính liên kết tượng trưng chứ không phải tài nguyên mà nó đang trỏ tới.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              292Khi được đặt, một nỗ lực sẽ được thực hiện để giảm thiểu hiệu ứng bộ nhớ đệm của tệp I/O.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              293Cờ cho biết mở tệp ở chế độ không chặn khi có thể.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              294Khi được đặt, ánh xạ tệp bộ nhớ được sử dụng để truy cập tệp. Cờ này chỉ khả dụng trên hệ điều hành Windows. On other operating systems, this flag is ignored

                              Trên Windows, chỉ có

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              284,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              279,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              280,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              276,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              278,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              283,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              277 và
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              294

                              Hằng số loại tệp #

                              Các hằng số sau đây được dùng với thuộc tính

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              48 của đối tượng để xác định loại tệp

                              ConstantDescription
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              304Bit mask được sử dụng để trích xuất mã loại tệp.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              305Hằng số loại tệp cho một tệp thông thường.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              306Hằng số loại tệp cho một thư mục.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              307Hằng số loại tệp cho tệp thiết bị định hướng ký tự.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              308Hằng số loại tệp cho tệp thiết bị hướng khối.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              309Hằng số loại tệp cho FIFO/đường ống.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              310Hằng số loại tệp cho một liên kết tượng trưng.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              311Hằng số loại tệp cho ổ cắm

                              Trên Windows, chỉ có

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              307,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              306,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              310,
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              304 và
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              305

                              Hằng số chế độ tệp #

                              Các hằng số sau đây được dùng với thuộc tính

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              48 của đối tượng để xác định quyền truy cập đối với một tệp

                              ConstantDescription
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              318Chế độ tệp cho biết chủ sở hữu có thể đọc, ghi và thực thi.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              319Chế độ tệp cho biết chủ sở hữu có thể đọc được.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              320Chế độ tệp cho biết chủ sở hữu có thể ghi.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              321Chế độ tệp cho biết chủ sở hữu có thể thực thi được.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              322Chế độ tệp cho biết có thể đọc, ghi và thực thi theo nhóm.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              323File mode indicating readable by group.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              324File mode indicating writable by group.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              325Chế độ tệp cho biết có thể thực thi theo nhóm.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              326Chế độ tệp cho biết người khác có thể đọc, ghi và thực thi.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              327Chế độ tệp cho biết người khác có thể đọc được.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              328Chế độ tệp cho biết người khác có thể ghi.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              329Chế độ tệp cho biết người khác có thể thực thi được

                              Trên Windows, chỉ có

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              319 và
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              320

                              Ghi chú #

                              Thứ tự gọi lại và các hoạt động dựa trên lời hứa #

                              Bởi vì chúng được thực thi không đồng bộ bởi nhóm luồng bên dưới, nên không có thứ tự được đảm bảo khi sử dụng phương pháp gọi lại hoặc dựa trên lời hứa

                              Ví dụ: phần sau dễ bị lỗi vì thao tác

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              330 có thể hoàn thành trước thao tác
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              333

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              0

                              Điều quan trọng là phải sắp xếp đúng thứ tự các thao tác bằng cách đợi kết quả của thao tác này trước khi gọi thao tác kia

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              1

                              Hoặc, khi sử dụng API gọi lại, hãy di chuyển lệnh gọi

                              import * as fs from 'node:fs';const fs = require('node:fs');
                              330 vào lệnh gọi lại của hoạt động
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              333

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              2

                              Đường dẫn tệp#

                              Hầu hết các hoạt động của

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              56 chấp nhận đường dẫn tệp có thể được chỉ định ở dạng chuỗi, a hoặc đối tượng bằng giao thức
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              54

                              Đường dẫn chuỗi #

                              Đường dẫn chuỗi được hiểu là chuỗi ký tự UTF-8 xác định tên tệp tuyệt đối hoặc tương đối. Relative paths will be resolved relative to the current working directory as determined by calling

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              338

                              Ví dụ sử dụng đường dẫn tuyệt đối trên POSIX

                              Ví dụ sử dụng đường dẫn tương đối trên POSIX (liên quan đến

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              338)

                              Đường dẫn URL tệp #

                              Đối với hầu hết các hàm mô-đun

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              4, đối số
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              47 hoặc
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              12 có thể được truyền dưới dạng đối tượng bằng cách sử dụng giao thức
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              54

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              3

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              54 URL luôn là đường dẫn tuyệt đối

                              Cân nhắc dành riêng cho nền tảng#

                              Trên Windows,

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              54 s với tên máy chủ chuyển đổi thành đường dẫn UNC, trong khi
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              54 s với ký tự ổ đĩa chuyển đổi thành đường dẫn tuyệt đối cục bộ.
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              54 s không có tên máy chủ và không có ký tự ổ đĩa sẽ dẫn đến lỗi

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              54 s với ký tự ổ đĩa phải sử dụng
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              349 làm dấu phân cách ngay sau ký tự ổ đĩa. Sử dụng dấu phân cách khác sẽ dẫn đến lỗi

                              Trên tất cả các nền tảng khác,

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              54 s có tên máy chủ không được hỗ trợ và sẽ gây ra lỗi

                              Một

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              54 có các ký tự gạch chéo được mã hóa sẽ dẫn đến lỗi trên tất cả các nền tảng

                              Trên Windows,

                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              54 s có dấu gạch chéo ngược được mã hóa sẽ dẫn đến lỗi

                              Đường dẫn đệm #

                              Đường dẫn được chỉ định bằng cách sử dụng a chủ yếu hữu ích trên một số hệ điều hành POSIX coi đường dẫn tệp là chuỗi byte mờ. Trên các hệ thống như vậy, một đường dẫn tệp duy nhất có thể chứa các chuỗi con sử dụng nhiều mã hóa ký tự. Như với đường dẫn chuỗi, đường dẫn có thể là tương đối hoặc tuyệt đối

                              Ví dụ sử dụng đường dẫn tuyệt đối trên POSIX

                              Thư mục làm việc trên mỗi ổ đĩa trên Windows#

                              Trên Windows, Nút. js tuân theo khái niệm thư mục làm việc trên mỗi ổ đĩa. Hành vi này có thể được quan sát thấy khi sử dụng đường dẫn ổ đĩa không có dấu gạch chéo ngược. Ví dụ:

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              353 có khả năng trả về một kết quả khác với
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              354. Để biết thêm thông tin, hãy xem trang MSDN này

                              File descriptors#

                              Trên các hệ thống POSIX, đối với mọi quy trình, kernel duy trì một bảng các tệp và tài nguyên hiện đang mở. Mỗi tệp đang mở được gán một mã định danh số đơn giản được gọi là bộ mô tả tệp. At the system-level, all file system operations use these file descriptors to identify and track each specific file. Các hệ thống Windows sử dụng một cơ chế khác nhưng tương tự về mặt khái niệm để theo dõi tài nguyên. Để đơn giản hóa mọi thứ cho người dùng, Node. js trừu tượng hóa sự khác biệt giữa các hệ điều hành và gán cho tất cả các tệp đang mở một bộ mô tả tệp số

                              Các phương thức

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              64 dựa trên gọi lại và
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              93 đồng bộ mở một tệp và phân bổ một bộ mô tả tệp mới. Sau khi được phân bổ, bộ mô tả tệp có thể được sử dụng để đọc dữ liệu, ghi dữ liệu vào hoặc yêu cầu thông tin về tệp

                              Hệ điều hành giới hạn số lượng bộ mô tả tệp có thể được mở tại bất kỳ thời điểm nào, do đó, điều quan trọng là phải đóng bộ mô tả khi hoàn thành các thao tác. Không làm như vậy sẽ dẫn đến rò rỉ bộ nhớ, cuối cùng sẽ khiến ứng dụng bị sập

                              Các API dựa trên lời hứa sử dụng một đối tượng thay cho bộ mô tả tệp số. Các đối tượng này được hệ thống quản lý tốt hơn đảm bảo tài nguyên không bị rò rỉ. Tuy nhiên, chúng vẫn được yêu cầu đóng lại khi hoạt động hoàn tất

                              Sử dụng threadpool #

                              Tất cả API hệ thống tệp gọi lại và dựa trên lời hứa (ngoại trừ

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              357) đều sử dụng nhóm luồng của libuv. Điều này có thể có ý nghĩa hiệu suất đáng ngạc nhiên và tiêu cực đối với một số ứng dụng. Xem tài liệu
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              358 để biết thêm thông tin

                              Cờ hệ thống tập tin #

                              Các cờ sau có sẵn ở bất cứ nơi nào tùy chọn

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              359 lấy một chuỗi

                              • import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                360. Open file for appending. Tệp được tạo nếu nó không tồn tại

                              • import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                361. Giống như
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                360 nhưng không thành công nếu đường dẫn tồn tại

                              • import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                363. Mở tệp để đọc và nối thêm. Tệp được tạo nếu nó không tồn tại

                              • import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                364. Giống như
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                363 nhưng không thành công nếu đường dẫn tồn tại

                              • import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                366. Mở tệp để nối thêm ở chế độ đồng bộ. Tệp được tạo nếu nó không tồn tại

                              • import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                367. Mở tệp để đọc và nối thêm ở chế độ đồng bộ. Tệp được tạo nếu nó không tồn tại

                              • import { unlink } from 'node:fs';
                                
                                unlink('/tmp/hello', (err) => {
                                  if (err) throw err;
                                  console.log('successfully deleted /tmp/hello');
                                });const { unlink } = require('node:fs');
                                
                                unlink('/tmp/hello', (err) => {
                                  if (err) throw err;
                                  console.log('successfully deleted /tmp/hello');
                                });
                                57. Mở tệp để đọc. Một ngoại lệ xảy ra nếu tệp không tồn tại

                              • import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                369. Open file for reading and writing. Một ngoại lệ xảy ra nếu tệp không tồn tại

                              • import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                370. Mở tệp để đọc và ghi ở chế độ đồng bộ. Hướng dẫn hệ điều hành bỏ qua bộ đệm ẩn của hệ thống tệp cục bộ

                                This is primarily useful for opening files on NFS mounts as it allows skipping the potentially stale local cache. Nó có tác động rất thực đến hiệu năng I/O nên không nên sử dụng cờ này trừ khi cần thiết

                                Điều này không biến

                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                64 hoặc
                                import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                                03 thành cuộc gọi chặn đồng bộ. Nếu muốn hoạt động đồng bộ, nên sử dụng một cái gì đó như
                                import { open } from 'node:fs/promises';
                                
                                const fd = await open('sample.txt');
                                fd.createReadStream({ start: 90, end: 99 });
                                93

                              • import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                374. Mở tệp để viết. Tệp được tạo (nếu không tồn tại) hoặc bị cắt bớt (nếu tồn tại)

                              • import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                375. Giống như
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                374 nhưng không thành công nếu đường dẫn tồn tại

                              • import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                377. Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists)

                              • import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                378. Like
                                import { unlink } from 'node:fs/promises';
                                
                                try {
                                  await unlink('/tmp/hello');
                                  console.log('successfully deleted /tmp/hello');
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }const { unlink } = require('node:fs/promises');
                                
                                (async function(path) {
                                  try {
                                    await unlink(path);
                                    console.log(`successfully deleted ${path}`);
                                  } catch (error) {
                                    console.error('there was an error:', error.message);
                                  }
                                })('/tmp/hello');
                                377 but fails if the path exists

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              359 can also be a number as documented by
                              import { unlink } from 'node:fs';
                              
                              unlink('/tmp/hello', (err) => {
                                if (err) throw err;
                                console.log('successfully deleted /tmp/hello');
                              });const { unlink } = require('node:fs');
                              
                              unlink('/tmp/hello', (err) => {
                                if (err) throw err;
                                console.log('successfully deleted /tmp/hello');
                              });
                              58; commonly used constants are available from
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              47. On Windows, flags are translated to their equivalent ones where applicable, e. g.
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              277 to
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              384, or
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              385 to
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              386, as accepted by
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              387

                              The exclusive flag

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              388 (
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              280 flag in
                              import { unlink } from 'node:fs';
                              
                              unlink('/tmp/hello', (err) => {
                                if (err) throw err;
                                console.log('successfully deleted /tmp/hello');
                              });const { unlink } = require('node:fs');
                              
                              unlink('/tmp/hello', (err) => {
                                if (err) throw err;
                                console.log('successfully deleted /tmp/hello');
                              });
                              58) causes the operation to return an error if the path already exists. On POSIX, if the path is a symbolic link, using
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              280 returns an error even if the link is to a path that does not exist. Cờ độc quyền có thể không hoạt động với hệ thống tệp mạng

                              On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file

                              Sửa đổi một tệp thay vì thay thế nó có thể yêu cầu tùy chọn

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              359 được đặt thành
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              369 thay vì mặc định là
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              374

                              Hành vi của một số cờ là dành riêng cho nền tảng. Như vậy, việc mở một thư mục trên macOS và Linux bằng cờ

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              363, như trong ví dụ bên dưới, sẽ trả về lỗi. Ngược lại, trên Windows và FreeBSD, một bộ mô tả tệp hoặc một
                              import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                              02 sẽ được trả về

                              Trên Windows, mở một tệp ẩn hiện có bằng cờ

                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              374 (thông qua
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              64,
                              import { open } from 'node:fs/promises';
                              
                              const fd = await open('sample.txt');
                              fd.createReadStream({ start: 90, end: 99 });
                              76 hoặc
                              import * as fs from 'node:fs/promises';const fs = require('node:fs/promises');
                              03) sẽ không thành công với
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              528. Các tệp ẩn hiện có có thể được mở để ghi bằng cờ
                              import { unlink } from 'node:fs/promises';
                              
                              try {
                                await unlink('/tmp/hello');
                                console.log('successfully deleted /tmp/hello');
                              } catch (error) {
                                console.error('there was an error:', error.message);
                              }const { unlink } = require('node:fs/promises');
                              
                              (async function(path) {
                                try {
                                  await unlink(path);
                                  console.log(`successfully deleted ${path}`);
                                } catch (error) {
                                  console.error('there was an error:', error.message);
                                }
                              })('/tmp/hello');
                              369

                              JavaScript có thể mở tệp cục bộ không?

                              Trình duyệt web (và JavaScript) chỉ có thể truy cập các tệp cục bộ khi có sự cho phép của người dùng . Để chuẩn hóa quyền truy cập tệp từ trình duyệt, W3C đã xuất bản API tệp HTML5 vào năm 2014. Nó xác định cách truy cập và tải lên các tệp cục bộ bằng các đối tượng tệp trong các ứng dụng web.

                              Bạn có thể đọc một tệp bằng JavaScript không?

                              Để đọc tệp, sử dụng FileReader , cho phép bạn đọc nội dung của đối tượng Tệp vào bộ nhớ. Bạn có thể hướng dẫn FileReader đọc tệp dưới dạng bộ đệm mảng, URL dữ liệu hoặc văn bản.

                              Có xử lý tệp trong JavaScript không?

                              Xử lý tệp trong JavaScript là một kỹ thuật trong đó tệp được viết ở định dạng html bằng cách sử dụng CSS có thể được gọi bằng cách sử dụng tệp html bên ngoài hoặc sử dụng. tệp js trỏ đến tệp html đó . Thao tác xử lý tệp trong JavaScript bao gồm mở tệp, đóng tệp, Cập nhật dữ liệu trong tệp.