title: const fs = require("fs") not working correctly on Node js
body: <p>This is my first post here so i apologise if i make an error.</p>
  
  <p>I am having an problem when trying to use const fs = require("fs") in Node js. Visual Studio code IDE is not recognising it as being assigned and when i try to use fs.writeFile i am getting an error.</p>
  
  <p>I have already tried looking online but can not find any solution. I am new to coding and would appreciate some help on this.</p>
  
  <pre><code>const http = require("http");
  const fs = require("fs");
  
  const server = http.createServer((req, res) =&gt; {
    const url= req.url;
  
    const method = req.method;
    if (url === "/") {
      res.write("&lt;html&gt;");
      res.write("&lt;head&gt;&lt;title&gt;Enter Message&lt;/title&gt;&lt;/head&gt;");
      res.write("&lt;body&gt;&lt;form action='/message' method='POST'&gt;&lt;input type='text' name='message'&gt;&lt;button type='submit'&gt;Enter&lt;/button&gt;&lt;/input&gt;&lt;/form&gt;");
      res.write("&lt;/html&gt;");
      return res.end();
    }
    if (url === "/message" &amp;&amp; method === "POST") {
      fs.writeFile("message.txt", "DUMMY");
    }
    res.setHeader("content-type", "text/html");
    res.write("&lt;html&gt;");
    res.write("&lt;head&gt;&lt;title&gt;My First Page&lt;/title&gt;&lt;/head&gt;");
    res.write("&lt;body&gt;&lt;h1&gt;Hello From My Node Js Server!!!!&lt;/h1&gt;&lt;/body&gt;");
    res.write("&lt;html&gt;");
  });
  </code></pre>
  
  <p>I expected the dummy text to be written to the file when i ran the program but i just get the following error.</p>
  
  <pre><code>TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
      at maybeCallback (fs.js:128:9)
      at Object.writeFile (fs.js:1158:14)
      at Server.http.createServer (C:\Users\garry\Documents\Eloquent Javascript\Practice\practice.js:15:8)
      at Server.emit (events.js:189:13)
      at parserOnIncoming (_http_server.js:676:12)
      at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)
  </code></pre>