- Prabhanshu Attri
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
nvm --version
Install NVM (Node Version Manager)
nvm install 8.9.1
node --version
npm --version
Install Node
npm install --save express
Installing NPM packages
node index.js
Running Node
var express = require('express');
var app = express();
app.set('port', (process.env.PORT || 5000));
app.use(function(req, res, next) {
console.log("User-agent: ", req.get('User-Agent'));
next();
});
app.get('/', function(req, res) {
res.json({
'hello': 'friend!'
});
});
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});
@PrabhanshuAttri
prabhanshu.com
@PrabhanshuAttri