How to get the amount of free or available space using Node.js?

March 19, 2021 - 1 min read

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 as integers.

See the above code live in repl.it.

Feel free to share if you found this useful 😃.