To determine the size of a file in NodeJS (e.g. to get the size of myfile.txt) use fs.stat() or fs.statSync() like this: const fs = require("fs"); //Load the filesystem module const stats = fs.statSync("myfile.txt"); const fileSizeInBytes = stats.size; //Convert the file size to megabytes (optional) const fileSizeInMegabytes = fileSizeInBytes / 1000000.0;