os.path.exists code example

Example 1: python os.path.isdir exception

import os

if os.path.isdir(root_folder):
    print('Ok')
else:
    print('Nok')

Example 2: node if path exists

const fs = require("fs"); // Or `import fs from "fs";` with ESM
if (fs.existsSync(path)) {
    // Do something
}

Example 3: python join paths

import os

# Join paths using OS import. Takes any amount of arguments
path = os.path.join('/var/www/public_html', './app/', ".\\my_file.json")

print(path) # /var/www/public_html/app/myfile.json