FS Module File Status
Medium
0.0% Acceptance
In this lab, you'll learn how to use Node.js's fs.fstat() method to retrieve information about a file. This method allows you to retrieve the file's metadata, such as the file size, mode, and modification time. Your task is to read the file sample.txt
and print the file size in bytes using the fs.fstat()
method.
Challenges:
- Import
fs
and usefs.promises
. - Open the
sample.txt
file usingfs.open()
. - Retrieve file descriptor using
fs.fstat()
. - Print the file size in bytes.