How to get the amount of free or available space using Node.js?
Published March 19, 2021
To get the amount of free or available memory space, you can use the freemem()
method from the os
module in Node.js.
/* Get free memory space in Node.js */
// import os module
const os = require("os");
// check the available memory
const availableMemory = os.freemem();
- The method returns the available memory in
bytes
asintegers
.
See the above code live in repl.it.