Skip to content

Poop Code

  • Home
  • Linux

Get File Size in Node JS

November 5, 2024 by poopcode
var fs = require("fs"); // Load the filesystem module
var stats = fs.statSync("myfile.txt")
var fileSizeInBytes = stats.size;
// Convert the file size to megabytes (optional)
var fileSizeInMegabytes = fileSizeInBytes / (1024*1024);
Categories Node JS, Typescript Tags node js, typescript
Hotkey Python With Code Examples
How to kill a zombie process in Linux?
© 2025 Poop Code • Built with GeneratePress