title: Problems loading static js files on Express js
body: <p>I'm trying to run some static javascript files that I've on <code>/public/js</code> folder.</p>
  
  <p>On that folder I've a script named test.js that it simply has a <code>console.log('test');</code> inside.</p>
  
  <p>On mi index.html I call this file using the following route:</p>
  
  <p><code>&lt;script type="text/javascript" src="/js/test.js"&gt;&lt;/script&gt;</code></p>
  
  <p>And this is my index.js file where I've the express server:</p>
  
  <pre><code>const path = require("path");
  const express = require("express");
  const app = express();
  
  app.use(require("body-parser").json({}));
  
  app.listen(3000, () =&gt; {
    console.log("server started");
  });
  
  app.use(express.static(path.join(__dirname, "public")));
  
  app.get("/", (req, res) =&gt; {
    res.sendFile(path.join(__dirname, "/index.html"));
  });
  </code></pre>
  
  <p>I don't know what I'm doing wrong, please if someone could assist me it will be really helpful.</p>
  
  <p>Thanks everyone!</p>