Node fs.js running in HTML

2

Hello, I need to use the fs function of node.js but I'm encountering errors. When I run using node use_fs.js it runs and works perfectly. However when I put it inside the html it always says q require is not defined. I know that fs is a core function of node.js, but when

<script language="javascript">
          var fs = require('fs');
          var fileContent = "Hello World!";
          var filepath = '_folder/file.txt';
          fs.writeFile(filepath, fileContent, function (err) {
            if (err) throw err;
            console.log('Saved!');
          });
    </script>

Can anyone give a tip?

    
asked by anonymous 28.03.2018 / 01:20

0 answers