To get the path or location to the temporary files directory, you can use the tmpdir()
method from the os
module in Node.js.
/* Get path of temporary files directory in Node.js */
// import os module
const os = require("os");
// get temp directory
const tempDir = os.tmpdir(); // /tmp
- The method returns the path to the temporary files directory as a
string
.
See the above code live in repl.it.