title: How to do npm module installations from the script file itlself
body: <p>I have a file server.js in which I am starting multiple servers.
  eg.</p>
  
  <pre><code>var engine = require('engine.io');
  var server = engine.listen(80);
  </code></pre>
  
  <p>And if the engineio module is not installed in the current directory by using the </p>
  
  <pre><code>npm install engine.io
  </code></pre>
  
  <p>It throws an error<br></p>
  
  <pre><code>Error: Cannot find module 'engine.io'
  </code></pre>
  
  <p>Now on a machine where this server has to be deployed I want handle all these npm module installation dependencies from the script file itself.</p>
  
  <p>How can i do this from my server.js file only</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>As suggested i tried following the post <br>
  <a href="https://stackoverflow.com/questions/15957529/can-i-install-a-npm-package-from-javascript-running-in-node-js">Can I install a NPM package from javascript running in Node.js?</a></p>
  
  <p>but it throws an error when it searches for a node module "npm"
  at :<br></p>
  
  <pre><code>var npm = require("npm");
  </code></pre>
  
  <p>Reason : i dont have the node modules installed on my machine. ( and so its not having node_modules folder in my working directory)</p>
  
  <p><strong>Also,</strong><br></p>
  
  <p>I created a batch file in my working directory and put the following into it</p>
  
  <pre><code>npm install engine.io
  npm install eyes
  </code></pre>
  
  <p>And when i run it, <br></p>
  
  <p>It only installs the first module and then exits</p>
  
  <p>Thanks</p>