title: export json object from .json file to vue through express and assign it to the variable
body: <p>I would like to display on my page some data which I have in dsa.json file. I am using express with vue.</p>
  
  <p>Here's my code from the server.js:</p>
  
  <pre><code>var data;
  fs.readFile('./dsa.json', 'utf8', (err, data) =&gt; { 
    if (err) throw err;
    exports.data = data;
  });
  </code></pre>
  
  <p>Here's code from between <code>&lt;script&gt;</code> tags in index.html</p>
  
  <pre><code>var server = require(['../server']);
  var data = server.data;
  var scoreboards = new Vue({
      el: '#scoreboard',
      data: {
          students: data
      }
  });
  </code></pre>
  
  <p>I am using requirejs (CDN) to require server between <code>&lt;script&gt;</code> tags in index.html.</p>
  
  <p>index.html is in public directory whereas dsa.json and server.js are in the main catalogue.</p>
  
  <p>Here are the errors I get in the client:</p>
  
  <pre><code>require.min.js:1 GET http://localhost:3000/server.js 
  require.min.js:1 Uncaught Error: Script error for "../server"
  </code></pre>
  
  <p>I think it has something to do with context and scope but I don't know what exactly. </p>
  
  <p>I am using Chrome.</p>