title: import or require js file in another js file
body: <p>I'm not sure if this has been answered before. I am trying to build a node express API, where I now need to include another js file so I can spread up my code. </p>
  
  <p>Basically, I have a server.js file where I want to call a function in a router.js file. Is this possible?</p>
  
  <p>Have tried using import, because i read that ES6 now supports that.
  <strong>Code:</strong></p>
  
  <pre><code>import routers from '/router.js';
  </code></pre>
  
  <p>Have also tried with the 'required' keyword, but that does not help either. The router.js file is also just placed in the root as the server.js. </p>
  
  <p><strong>Package.json:</strong></p>
  
  <pre><code> {
      "name": "nodeexpresapi",
      "main": "server.js",
      "dependencies": {
        "body-parser": "~1.0.1",
        "express": "~4.0.0",
        "mongoose": "~3.6.13",
        "nodemon": "^1.9.2",
      },
      "scripts": {
        "start": "nodemon server.js"
      }
   }
  </code></pre>
  
  <p>I have read that you can import them in the html file, but this is a server with no html, so that is not possible for me.</p>