Complete the code to import the 'fs' module using CommonJS syntax.
const fs = require([1]);In CommonJS, modules are imported using require() with the module name as a string. The correct module name for file system operations is 'fs'.
Complete the code to import the 'fs' module using ESM syntax.
import fs from [1];
In ESM (ECMAScript Modules), you import modules using import with the module name as a string. The correct module name for the file system is 'fs'.
Fix the error in exporting a function named 'greet' using CommonJS syntax.
module.exports = [1];In CommonJS, to export a function, you assign the function name (without parentheses) to module.exports. Using greet exports the function itself.
Fill both blanks to export a named function 'greet' using ESM syntax.
[1] function greet() { console.log('Hello'); } [2]
In ESM, you export a named function by placing export before the function declaration. No extra export statement is needed after the function.
Fill all three blanks to import a named export 'greet' from 'greetings.js' using ESM syntax.
import [1] from [2]; [3]();
To import a named export in ESM, use curly braces around the name. The module path is a string with relative path. Then call the imported function by its name.