How to find detect file size in Node.js

Published Saturday, January 16, 2021

Jonas Arnklint

Using the fs.stat function you can retreive the file size in bytes of any file in the file system:

this is my code 413

The fs.stat is useful in other contexts as well, such as when determining when a file was created or modified.