MSNCodeSNIPPETS← msncode.dev
snippets/nodejs

Write File Synchronously

Write content to a file with fs.writeFileSync

nodejsjavascriptfilewrite
JAVASCRIPT
require('fs').writeFileSync('output.txt', 'content');

More nodejs snippets

Check if Directory Exists

Check if a path exists and is a directory

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