Installing Node
-
Install Node Version Manager (NVM):
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash
-
Verify the installation:
command -v nvm
-
Install the latest version of node:
nvm install node
-
Install Express to make life easier:
npm install --save express
Hello World Example
-
server.js:
var express = require('express'); var app = express(); app.get('/', function(req, res){ res.end('hello world'); }); app.listen(3000); console.log("listening on port 3000");
-
Test on terminal:
node server.js & # WAIT A BIT ... wget localhost:3000 cat index.html
-
To end testing:
kill -9 $(pgrep node)