title: Run function in index.js from script in public folder
body: <p>I am trying to run a script in my main index.js file from a script in the public folder. I do not know how to link the two.</p>
  
  <p>I am trying to do this because I need to run file system operations on the server side. I have tried to link the script in the main HTML file, but when I try to run the function, it cannot be found.</p>
  
  <p>my index file:</p>
  
  <pre><code>const express = require('express');
  const bodyParser = require('body-parser');
  var fs = require("fs");
  
  const app = express();
  
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: true }));
  
  app.use(express.static('public'));
  
  app.get('/', (req, res) =&gt; {
    res.sendFile('public/index.html');
  });
  
  app.listen(3000, () =&gt; console.log('server started'));
  
  function test() {
    console.log("test");
  }
  </code></pre>
  
  <p>my script in the public folder just has <code>test();</code></p>
  
  <p>my linking HTML</p>
  
  <pre class="lang-html prettyprint-override"><code> &lt;script src="script.js"&gt;&lt;/script&gt;
   &lt;script src="../index.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I am expecting the test function to run, and log 'test'. It does not, and i get no console logs or errors.</p>
  
  <p>All code is available <a href="https://repl.it/@LukeZeller/NBShell-NodeJS-Beta" rel="nofollow noreferrer">on repl.it</a></p>