0

Based on another thread from here on StackExchange, I tried using a code (package: file-system node.js) but it doesn't work. Where have I made a mistake?

        <html>
        <script>
        window.onload = function() {
        var fs = require('fs');
        var files = fs.readdirSync('/Personal/Week4');
        var output = document.getElementById("field");
        output.innerHTML = files;
        </script>
        <body>
        <div id="field">
        <p>asd</p>
        </div>

        </body>

        </html>
D. Richard
  • 460
  • 3
  • 12
  • If you want to run server side code, then you have to run it on the server. You can't send it to the client, embedded in a ` – Quentin Feb 17 '17 at 11:23
  • Thanks that's very helpful! I didn't know there was a difference between running code server or client side. How may I be able to run it (or something else) on the server-side? – D. Richard Feb 17 '17 at 11:30
  • Or how can I run it on the server so that the filenames on the server are outputted on the client? – D. Richard Feb 17 '17 at 11:31
  • http://stackoverflow.com/questions/7947195/start-with-node-js-as-a-complete-server-side-newbie – Quentin Feb 17 '17 at 11:32

0 Answers0