Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If your goal is to simply display some static files you can use the Connect package. I have had some success (I'm still pretty new to NodeJS myself), using it and the twitter bootstrap API in combination.</p> <p>at the command line </p> <pre><code>:\&gt; cd &lt;path you wish your server to reside&gt; :\&gt; npm install connect </code></pre> <p>Then in a file (I named) Server.js</p> <pre><code>var connect = require('connect'), http = require('http'); connect() .use(connect.static('&lt;pathyouwishtoserve&gt;')) .use(connect.directory('&lt;pathyouwishtoserve&gt;')) .listen(8080); </code></pre> <p>Finally </p> <pre><code>:\&gt;node Server.js </code></pre> <p>Caveats:</p> <p>If you don't want to display the directory contents, exclude the .use(connect.directory line.</p> <p>So I created a folder called "server" placed index.html in the folder and the bootstrap API in the same folder. Then when you access the computers IP:8080 it's automagically going to use the index.html file.</p> <p>If you want to use port 80 (so just going to http://, and you don't have to type in :8080 or some other port). you'll need to start node with sudo, I'm not sure of the security implications but if you're just using it for an internal network, I don't personally think it's a big deal. Exposing to the outside world is another story.</p> <h1>Update 1/28/2014:</h1> <p>I haven't had to do the following on my latest versions of things, so try it out like above first, if it doesn't work (and you read the errors complaining it can't find nodejs), go ahead and possibly try the below.</p> <h1>End Update</h1> <p>Additionally when running in ubuntu I ran into a problem using nodejs as the name (with NPM), if you're having this problem, I recommend using an alias or something to "rename" nodejs to node.</p> <p>Commands I used (for better or worse):</p> <p>Create a new file called node </p> <pre><code>:\&gt;gedit /usr/local/bin/node #!/bin/bash exec /nodejs "$@" sudo chmod -x /usr/local/bin/node </code></pre> <p>That ought to make </p> <pre><code>node Server.js </code></pre> <p>work just fine</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload