title: Creating a server and referencing API in node.js server (EdgeJS)
body: <p>I am having issues with getting my node.js server running when referencing my api module in the node.js server. </p>
  
  <pre><code>public static async void Start()
  {
      var data = 9;
  
      var createHttpServer = Edge.Func(File.ReadAllText("../../../../server/server.js"));
  
  
      await createHttpServer(new
      {
          port = 3333,
      });
  
  
  }
  
  static void Main(string[] args)
  {
      Task.Run((Action)Start).Wait();
      Application.Run(new Form1());
  }
  </code></pre>
  
  <p>server.js </p>
  
  <p>return function (options, cb) {</p>
  
  <pre><code>'use strict';
  var api = require('routes/api');
  var express    = require('express');                    // web framework
  var cors       = require('cors');                       // middleware for express
  var bodyParser = require('body-parser');                // parsing module
  var path       = require('path');
  var app = express();
  app.use(bodyParser.urlencoded({'extended': 'true'}));   // parse application/x-www-form-urlencoded
  app.use(bodyParser.json());
  //app.get('/api/getDeviceCatalog', api.getDeviceCatalog);
  //app.get('/api/getDeviceDetails', api.getDeviceDetails);
  //app.get('/api/getDeviceImages', api.getDeviceImages);// parse application/json
  
  // IMPORTANT!: This rule has to be last rule for routing as it has very common definition
  app.all('/*', function (request, response) {
      var fileName, serverPath;
      console.log('Send: ' + __dirname + request.url);
      serverPath = path.resolve(__dirname + '../../../../../../server/');
      fileName = serverPath + request.url;
  
      response.sendFile(fileName);
  });
  
  // start server listening on defined port
  app.listen(options.port);
  console.log('The NodeJS server is ready.');
  };
  </code></pre>
  
  <p>I can start the server and run it just fine if I remove this line</p>
  
  <pre><code>var api = require('routes/api');
  </code></pre>
  
  <p>I get an error </p>
  
  <pre class="lang-none prettyprint-override"><code>$exception  {"Error: Cannot find module 'routes/api'
  at Function.Module._resolveFilename (module.js:336:15)
  at Function.Module._load (module.js:286:25)
  at Module.require (module.js:365:17)
  at require (module.js:384:17)
  at eval (eval at &lt;anonymous
  (C:\\TechSpikeUDC\\TechSpikeUDC\\TechSpikeUDC\\bin\\x86\\Debug\\edge\\double_edge.js:34:28), &lt;anonymous&gt;:37:15)"}   System.Exception
  </code></pre>