title: why script don't save data to json file?
body: <p>i make registration form with html but when i click on button script don't work and data don't save to json file. function is work and there is alert on page but other part of code don't work why?</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
  &lt;meta charset=&quot;UTF-8&quot;&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
  
  &lt;label for=&quot;email&quot;&gt;&lt;b&gt;Email&lt;/b&gt;&lt;/label&gt;
  &lt;input type=&quot;text&quot; placeholder=&quot;Enter Email&quot; name=&quot;email&quot;          id=&quot;email&quot; required&gt;
  
  &lt;label for=&quot;psw&quot;&gt;&lt;b&gt;Password&lt;/b&gt;&lt;/label&gt;
  &lt;input type=&quot;password&quot; placeholder=&quot;Enter Password&quot;      name=&quot;psw&quot; id=&quot;psw&quot; required&gt;
  &lt;button type=&quot;submit&quot; class=&quot;registerbtn&quot;     onclick=&quot;myFunction()&quot;&gt;Register&lt;/button&gt;
  
  
   &lt;script src = &quot;script.js&quot;&gt;&lt;/script&gt;
   &lt;/body&gt;
  
   &lt;/html&gt;
  
   function myFunction()
   {
   alert('work!!!')
   const fs = require('fs');
  
   var x = document.getElementById(&quot;email&quot;).value;
   var y = document.getElementById(&quot;psw&quot;).value;
  
   let student = {
      name: 'dato',
      password: 'rame',
   };
  
  let data = JSON.stringify(student);
  
  fs.writeFileSync('data.json', data, finished);
  
  function finished(err)
  {
      console.log('success');
  }
  }
  </code></pre>