Node.js

20131229 On Windows

Thanks to http://blog.gvm-it.eu/post/20404719601/getting-started-with-node-js-on-windows

---------------------

Download from http://nodejs.org/download/ and install

- Ensure add to path is left selected

Run cmd and at prompt >node to tests whether enters command line

Yay, CTRL-C twice to exit

---------------------

Create a folder to hold your node assets, ie d:\_Node\

In CMD move to this folder first before entering the Node command line

---------------------

- to run a JS file from the current CMD folder:

  - node myjsfile.js

Example:

Create file helloworld.js

// our very first node program
console.log("Hello world!");

run it at cmd line when in d:\_node\

- node helloworld.js

---------------------

A simple webserver

create a new simpleserver.js file

// include http module var http = require('http'); // create server http.createServer(function (req, res) { // respond to any incoming http requests res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('I am alive!\n'); }).listen(1337, '127.0.0.1'); // log server started at localhost:1337 console.log('Server running at 127.0.0.1:1337');

run it:

- node simpleserver.js

access it at http://localhost:1337/

Stop it using CTRL-C

----------------

NPM:

At node command line in target folder ie d:\_node:

- npm install xml2js

Nice!

------------------------