Answers for "nodejs check if file is running on server or client"

17

node check if file exists

const fs = require("fs"); // Or `import fs from "fs";` with ESM
if (fs.existsSync(path)) {
    // Do something
}
Posted by: Guest on May-22-2020
0

nodejs check if file is running on server or client

function is_server() {
   return ! (typeof window != 'undefined' && window.document);
}
Posted by: Guest on April-02-2021

Code answers related to "nodejs check if file is running on server or client"

Code answers related to "Javascript"

Browse Popular Code Answers by Language