Created a file with the name of index.js and the code is
var x = require("fs");
console.log("Hello");
fs.writeFileSync("text.txt","Hello");
and when I run it I receive an error:
ReferenceError: fs is not defined
at Object.<anonymous> (G:\web\Node Js\index.js:3:1)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47