Node.js
Fondamental
Reading and writing files with the fs module

Type d'évaluation

Mise en situation réelle

Analyse

Intelligence Artificielle

Compétences ciblées

nodejs
fs
async
file-io
promises

Scénario Technique

Context A script must read a JSON configuration file, modify one field, and write the updated content back to disk. The Problem The developer is using synchronous blocking calls (fs.readFileSync) inside an async context, causing event loop blocking. Current Code const data = fs.readFileSync("config.json"); const config = JSON.parse(data); config.version = "2.0"; fs.writeFileSync("config.json", JSON.stringify(config)); Constraints Replace synchronous calls with fs.promises equivalents. Use async/await for readability. Handle file-not-found errors explicitly. Expected Deliverable A Node.js script using fs.promises to read, modify, and write a JSON file asynchronously with proper error handling.

Prêt à évaluer ce talent ?

Accédez à l'interface de test complète pour soumettre votre architecture ou votre code.

Commencer le Défis
    Node.js - Reading and writing files with the fs module | Défi Technique & Recrutement — CodeDuel