MSNCodeSNIPPETS← msncode.dev
snippets/nodejs

Check if Directory Exists

Check if a path exists and is a directory

nodejsjavascriptfsdirectory
JAVASCRIPT
const exists = require('fs').existsSync('./folder');

More nodejs snippets

Fetch with Timeout

Add a timeout to fetch requests using AbortController

Get Current Directory Path

Get the directory of the currently running script

Safe JSON Parse

Parse JSON without try-catch crashing your app

Read Environment Variable

Access environment variables in Node.js