The layout.jade is not working, why? - node.js

This is my configure file:
The layout.jade does not seem to be working. But the jade is working. I used Chrome to check, and am sure that the layout HTML is not loaded into the page.
module.exports = function(app, express, mongoose){
var config=this
app.configure(function (){
app.set('views',__dirname+'/views')
app.set('view engine','jade')
app.set('view options', {layout:true})
app.use(express.bodyParser())
app.use(express.methodOverride())
app.use(express.cookieParser())
app.use(express.session({secret: 'topsecret',store: new express.session.MemoryStore}))
app.use(express.static(app.path.join(app.application_root,"public")))
app.use(express.errorHandler({dumpExceptions:true,showStack:true}))
app.use(express.bodyParser({keepExtensions: true, uploadDir:"./public/uploads"}))
app.use(app.router)
})
/*DB part:*/
app.mongoose.connect('mongodb://localhost/dio_database')
return config
}
The render command:
app.get('/items/:id',function(req,res){
models.ItemModel.findOne({_id:req.params.id}).exec(function(err,item){
if (!err){
res.render('item.jade',item)
} else
return console.log(err)
})
})
My layout.jade, quite simple:
!!!
doctype 5
html
head
title "Dio"
link(rel='icon', href='favicon.ico', type='image/x-icon')
link(rel='shortcut', href='favicon.ico', type='image/x-icon')
link(rel="shortcut", href="favicon.ico", type="image/vnd.microsoft.icon")
link(rel="icon", href="favicon.ico", type="image/vnd.microsoft.icon")
script(src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js")
script(src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js")
script(src="./javascripts/underscore-min.js")
script(src="./javascripts/backbone-min.js")
link(rel='stylesheet', href='./css/main.css', type="text/css", media="screen")
body
div#topbar Dio--where shitty thing happens
div#main!= body
footer
p
| Node.js MVC template by XXX
And the following is my npm list:
├─┬ bcrypt#0.7.3
│ └── bindings#1.0.0
├─┬ express#3.0.3
│ ├── commander#0.6.1
│ ├─┬ connect#2.7.0
│ │ ├── bytes#0.1.0
│ │ ├── formidable#1.0.11
│ │ ├── pause#0.0.1
│ │ └── qs#0.5.1
│ ├── cookie#0.0.5
│ ├── cookie-signature#0.0.1
│ ├── crc#0.2.0
│ ├── debug#0.7.0
│ ├── fresh#0.1.0
│ ├── methods#0.0.1
│ ├── mkdirp#0.3.3
│ ├── range-parser#0.0.4
│ └─┬ send#0.1.0
│ └── mime#1.2.6
├── fs#0.0.0
├── imagemagick#0.1.3
├─┬ jade#0.27.7
│ ├── coffee-script#1.4.0
│ ├── commander#0.6.1
│ └── mkdirp#0.3.4
├─┬ mongodb#1.2.2
│ └── bson#0.1.5
├─┬ mongoose#3.4.0
│ ├── hooks#0.2.1
│ ├─┬ mongodb#1.1.11
│ │ └── bson#0.1.5
│ ├── ms#0.1.0
│ └── sliced#0.0.3
├─┬ node-static#0.6.5 extraneous
│ ├── colors#0.6.0-1
│ └─┬ optimist#0.3.5
│ └── wordwrap#0.0.2
└── path#0.4.9

Actually the reason for such problem is quite simple:
Express 3 no longer supports layout..But do not be sad. Actually Express 3 begins to adopt a more natural and easier way, which is called block/extends.
The basic usage should be like this:
// In layout file: layout.jade
html
head
title XXX
block scripts
body
block content
block footer
// in a extended file, for example index.jade:
extends layout
block scripts
//write javascript part
block content
// write content
block footer
// write the footer
It actually becomes easier and more flexible. Glad to get it finally. But it took me more than 2 hours.
I am just wondering why so few people mentioned this change more clearly and openly. Hope this post can help some people like me.

Related

Reading to or Writing from mongodb crashes Node App

In my Node Express app, I have these routes:
router.get('/', function (req, res) {
Products.find().sort({ 'popularity': 'desc' }).limit(8).exec(function (err, top8) {
if (err) {
console.log(err);
return;
}
console.log(top8);
res.render('index', { mostPopular: top8 });
})
});
router.post('/admin', function (req, res) {
var entry = req.body;
console.log("ENTRY");
console.log(entry);
var product = new Products({
name: entry.name,
type: entry.type,
subType: entry.subType,
popularity: entry.popularity,
price: entry.price
});
console.log("DB MODEL");
console.log(product);
product.save(function (error) {
if (error) { console.log(error) };
});
res.end();
})
When either POSTing to /admin or simply loading /, the page renders "this page cannot be reached". There are no errors in the Node command prompt or from Mongodb, only in Visual Studio do I see
The thread 'main thread' (0x1) has exited with code 0 (0x0).
The program '[8104] node.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.
However, data is being saved to and read from the db, somehow it's crashing the app afterwards without and errors being thrown (I've tried try/except fields)
EDIT: Result of npm list
├── bcrypt-nodejs#0.0.3
├─┬ body-parser#1.8.4
│ ├── bytes#1.0.0
│ ├── depd#0.4.5
│ ├── iconv-lite#0.4.4
│ ├── media-typer#0.3.0
│ ├─┬ on-finished#2.1.0
│ │ └── ee-first#1.0.5
│ ├── qs#2.2.4
│ ├── raw-body#1.3.0
│ └─┬ type-is#1.5.7
│ └─┬ mime-types#2.0.14
│ └── mime-db#1.12.0
├─┬ cookie-parser#1.3.5
│ ├── cookie#0.1.3
│ └── cookie-signature#1.0.6
├─┬ debug#2.0.0
│ └── ms#0.6.2
├─┬ express#4.9.8
│ ├─┬ accepts#1.1.4
│ │ ├─┬ mime-types#2.0.14
│ │ │ └── mime-db#1.12.0
│ │ └── negotiator#0.4.9
│ ├── cookie#0.1.2
│ ├── cookie-signature#1.0.5
│ ├── depd#0.4.5
│ ├── escape-html#1.0.1
│ ├─┬ etag#1.4.0
│ │ └── crc#3.0.0
│ ├── finalhandler#0.2.0
│ ├── fresh#0.2.4
│ ├── media-typer#0.3.0
│ ├── merge-descriptors#0.0.2
│ ├── methods#1.1.0
│ ├─┬ on-finished#2.1.1
│ │ └── ee-first#1.1.0
│ ├── parseurl#1.3.1
│ ├── path-to-regexp#0.1.3
│ ├─┬ proxy-addr#1.0.10
│ │ ├── forwarded#0.1.0
│ │ └── ipaddr.js#1.0.5
│ ├── qs#2.2.4
│ ├── range-parser#1.0.3
│ ├─┬ send#0.9.3
│ │ ├── destroy#1.0.3
│ │ ├── mime#1.2.11
│ │ ├── ms#0.6.2
│ │ └─┬ on-finished#2.1.0
│ │ └── ee-first#1.0.5
│ ├── serve-static#1.6.5
│ ├─┬ type-is#1.5.7
│ │ └─┬ mime-types#2.0.14
│ │ └── mime-db#1.12.0
│ ├── utils-merge#1.0.0
│ └── vary#1.0.1
├─┬ jade#1.6.0
│ ├── character-parser#1.2.0
│ ├── commander#2.1.0
│ ├─┬ constantinople#2.0.1
│ │ └─┬ uglify-js#2.4.24
│ │ ├── async#0.2.10
│ │ ├─┬ source-map#0.1.34
│ │ │ └── amdefine#1.0.0
│ │ ├── uglify-to-browserify#1.0.2
│ │ └─┬ yargs#3.5.4
│ │ ├── camelcase#1.2.1
│ │ ├── decamelize#1.2.0
│ │ ├── window-size#0.1.0
│ │ └── wordwrap#0.0.2
│ ├─┬ mkdirp#0.5.1
│ │ └── minimist#0.0.8
│ ├─┬ monocle#1.1.51
│ │ └─┬ readdirp#0.2.5
│ │ └─┬ minimatch#3.0.0
│ │ └─┬ brace-expansion#1.1.3
│ │ ├── balanced-match#0.3.0
│ │ └── concat-map#0.0.1
│ ├─┬ transformers#2.1.0
│ │ ├─┬ css#1.0.8
│ │ │ ├── css-parse#1.0.4
│ │ │ └── css-stringify#1.0.5
│ │ ├─┬ promise#2.0.0
│ │ │ └── is-promise#1.0.1
│ │ └─┬ uglify-js#2.2.5
│ │ ├─┬ optimist#0.3.7
│ │ │ └── wordwrap#0.0.3
│ │ └─┬ source-map#0.1.43
│ │ └── amdefine#1.0.0
│ ├── void-elements#1.0.0
│ └─┬ with#3.0.1
│ └─┬ uglify-js#2.4.24
│ ├── async#0.2.10
│ ├─┬ source-map#0.1.34
│ │ └── amdefine#1.0.0
│ ├── uglify-to-browserify#1.0.2
│ └─┬ yargs#3.5.4
│ ├── camelcase#1.2.1
│ ├── decamelize#1.2.0
│ ├── window-size#0.1.0
│ └── wordwrap#0.0.2
├─┬ mongoose#4.4.10
│ ├── async#1.5.2
│ ├── bson#0.4.21
│ ├── hooks-fixed#1.1.0
│ ├── kareem#1.0.1
│ ├─┬ mongodb#2.1.10
│ │ ├── es6-promise#3.0.2
│ │ ├─┬ mongodb-core#1.3.9
│ │ │ └─┬ require_optional#1.0.0
│ │ │ ├── resolve-from#2.0.0
│ │ │ └── semver#5.1.0
│ │ └─┬ readable-stream#1.0.31
│ │ ├── core-util-is#1.0.2
│ │ ├── inherits#2.0.1
│ │ ├── isarray#0.0.1
│ │ └── string_decoder#0.10.31
│ ├── mpath#0.2.1
│ ├── mpromise#0.5.5
│ ├─┬ mquery#1.10.0
│ │ ├── bluebird#2.10.2
│ │ ├── debug#2.2.0
│ │ └── sliced#0.0.5
│ ├── ms#0.7.1
│ ├── muri#1.1.0
│ ├── regexp-clone#0.0.1
│ └── sliced#1.0.1
├─┬ morgan#1.3.2
│ ├── basic-auth#1.0.0
│ ├── depd#0.4.5
│ └─┬ on-finished#2.1.0
│ └── ee-first#1.0.5
├─┬ passport#0.3.2
│ ├── passport-strategy#1.0.0
│ └── pause#0.0.1
├─┬ serve-favicon#2.1.7
│ ├─┬ etag#1.5.1
│ │ └── crc#3.2.1
│ ├── fresh#0.2.4
│ └── ms#0.6.2
└─┬ stylus#0.42.3
├── css-parse#1.7.0
├─┬ glob#3.2.11
│ ├── inherits#2.0.1
│ └─┬ minimatch#0.3.0
│ ├── lru-cache#2.7.3
│ └── sigmund#1.0.1
├── mkdirp#0.3.5
└── sax#0.5.8

NodeJs does not start

Edit: I changed the title for this question because it seemed more accurate.
So this is my package.json file:
{
"name": "application-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"express": "~4.0.0",
"static-favicon": "~1.0.0",
"morgan": "~1.0.0",
"cookie-parser": "~1.0.1",
"body-parser": "~1.0.0",
"debug": "~0.7.4",
"jade": "~1.3.0",
"mongodb": "*",
"monk": "*"
}
}
I don't really get an error after hitting npm install but it seems like node didn't install all dependencies. Because when we hit the exact same code on my collegue's pc his promt said a lot more feedback on installed dependencies and it worked fine there.
When i now hit "npm start" it just terminates after a few seconds without any response.
I know there is a bug with node at the moment and i already tried to clear my npm chache and adding the "npm update" command and it still doesn't work.
It seems like its a problem with my pc because, like i said, on my collegue's pc everything worked fine. I hope you have any ideas what could be the problem. Thanks a lot in advance!
Edit: Here's what the npm list command gives me:
├─┬ body-parser#1.0.2
│ ├── qs#0.6.6
│ ├─┬ raw-body#1.1.3
│ │ └── bytes#0.2.1
│ └─┬ type-is#1.1.0
│ └── mime#1.2.11
├─┬ cookie-parser#1.0.1
│ ├── cookie#0.1.0
│ └── cookie-signature#1.0.3
├── debug#0.7.4
├─┬ express#4.0.0
│ ├─┬ accepts#1.0.0
│ │ ├── mime#1.2.11
│ │ └── negotiator#0.3.0
│ ├── buffer-crc32#0.2.1
│ ├── cookie#0.1.0
│ ├── cookie-signature#1.0.3
│ ├── debug#0.8.0
│ ├── escape-html#1.0.1
│ ├── fresh#0.2.2
│ ├── merge-descriptors#0.0.2
│ ├── methods#0.1.0
│ ├── parseurl#1.0.1
│ ├── path-to-regexp#0.1.2
│ ├── qs#0.6.6
│ ├── range-parser#1.0.0
│ ├─┬ send#0.2.0
│ │ ├── debug#0.8.0
│ │ └── mime#1.2.11
│ ├─┬ serve-static#1.0.1
│ │ └─┬ send#0.1.4
│ │ ├── debug#0.8.0
│ │ ├── fresh#0.2.0
│ │ ├── mime#1.2.11
│ │ └── range-parser#0.0.4
│ ├─┬ type-is#1.0.0
│ │ └── mime#1.2.11
│ └── utils-merge#1.0.0
├─┬ jade#1.3.1
│ ├── character-parser#1.2.0
│ ├── commander#2.1.0
│ ├─┬ constantinople#2.0.0
│ │ └─┬ uglify-js#2.4.13
│ │ ├── async#0.2.10
│ │ ├─┬ optimist#0.3.7
│ │ │ └── wordwrap#0.0.2
│ │ ├─┬ source-map#0.1.33
│ │ │ └── amdefine#0.1.0
│ │ └── uglify-to-browserify#1.0.2
│ ├── mkdirp#0.3.5
│ ├─┬ monocle#1.1.51
│ │ └─┬ readdirp#0.2.5
│ │ └─┬ minimatch#0.2.14
│ │ ├── lru-cache#2.5.0
│ │ └── sigmund#1.0.0
│ ├─┬ transformers#2.1.0
│ │ ├─┬ css#1.0.8
│ │ │ ├── css-parse#1.0.4
│ │ │ └── css-stringify#1.0.5
│ │ ├─┬ promise#2.0.0
│ │ │ └── is-promise#1.0.0
│ │ └─┬ uglify-js#2.2.5
│ │ ├─┬ optimist#0.3.7
│ │ │ └── wordwrap#0.0.2
│ │ └─┬ source-map#0.1.33
│ │ └── amdefine#0.1.0
│ └─┬ with#3.0.0
│ └─┬ uglify-js#2.4.13
│ ├── async#0.2.10
│ ├─┬ optimist#0.3.7
│ │ └── wordwrap#0.0.2
│ ├─┬ source-map#0.1.33
│ │ └── amdefine#0.1.0
│ └── uglify-to-browserify#1.0.2
├─┬ mongodb#1.4.0
│ ├─┬ bson#0.2.7
│ │ └── nan#0.8.0
│ └── kerberos#0.0.3
├─┬ monk#0.8.1
│ ├── debug#0.8.0
│ ├─┬ mongoskin#0.4.4
│ │ └─┬ mongodb#1.1.11
│ │ └── bson#0.1.5
│ └── mpromise#0.4.4
├─┬ morgan#1.0.0
│ └── bytes#0.2.1
└── static-favicon#1.0.2
So it really looks like the dependencies have been installed (if I'm not completely wrong?). Still my "npm start" command terminates after just a few seconds... any guesses?
If you cleared the npm cache, try also removing all folders in your app's node_modules and run npm install again.
You might want to try starting your app in DEBUG mode and see if it gives you any hint:
DEBUG=express:* node ./bin/www
if the cursor is returning on node app.js(server.js or whatever the name of the js is) like shown below
c:/users/<project-path>:node app.js
c:/users/<project-path>:
Then you might be using express 4 generator
So try the following command
set DEBUG=<project-folder-name>:* & npm start
Not sure if this is resolved or ignored and found a workaround. Just had gone through the problem myself and found out that the problem was not with NodeJS but with one of the dependencies. I failed to install ejs and all my files are ejs based. So I got the same error as you.
So it is best to check if all your dependencies are installed properly.

Express connect logger missing some tokens

I'm using Node Express and logging using Connect Logger. Most tokens that I want to see, correctly log a value, but a number of them are coming up as hyphens. For instance the default log format is defined as:
default ':remote-addr - - [:date] ":method :url HTTP/:http-version"
:status :res[content-length] ":referrer" ":user-agent"'
but the following two tokens only display a hyphen (instead of an actual value):
:res[content-length]
:referrer
I've also attempted to define new tokens following Connect's content-type example:
express.logger.token('type', function(req, res){
return req.headers['content-type']; })
but again no luck. My end goal is to display the username making requests, but I can't even get the out-of-the-box experience to work, so am wondering if I have this set up correctly.
Here's my basic code setup:
var express = require('express')
, http = require('http')
, path = require('path')
, request = require('request')
, util = require('util')
, parseString = require('xml2js').parseString
, htmlDec = require('htmldec')
, users = require('./users')
, companies = require('./companies')
, app = module.exports = express()
, flash = require('connect-flash')
, passport = require('passport')
, LocalStrategy = require('passport-local').Strategy
, ensureLoggedIn = require('connect-ensure-login').ensureLoggedIn
, async = require('async')
, nodemailer = require("nodemailer")
, fs = require('fs')
, sanitizeHtml = require('sanitize-html')
, memwatch = require('memwatch');
app.server = require('http').createServer(app);
app.configure(function() {
app.set('views', __dirname + '/views');
app.set('view engine', 'html');
app.use(express.logger());
app.use(express.compress());
app.use(express.cookieParser());
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.session({/* are here in source */}));
app.engine('.html', require('ejs').__express);
app.use(flash());
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);
app.use('/styles', express.static(__dirname + '/styles'));
app.use(express.static(__dirname + '/../../public'));
});
npm ls
├── async#0.2.9
├── connect-ensure-login#0.1.1
├── connect-flash#0.1.1
├── ejs#0.8.4
├── escape-html#1.0.1 extraneous
├─┬ express#3.4.8
│ ├── buffer-crc32#0.2.1
│ ├─┬ commander#1.3.2
│ │ └── keypress#0.1.0
│ ├─┬ connect#2.12.0
│ │ ├── batch#0.5.0
│ │ ├── bytes#0.2.1
│ │ ├─┬ multiparty#2.2.0
│ │ │ ├─┬ readable-stream#1.1.11
│ │ │ │ ├── core-util-is#1.0.1
│ │ │ │ ├── debuglog#0.0.2
│ │ │ │ └── string_decoder#0.10.25-1
│ │ │ └── stream-counter#0.2.0
│ │ ├── negotiator#0.3.0
│ │ ├── pause#0.0.1
│ │ ├── qs#0.6.6
│ │ ├── raw-body#1.1.2
│ │ └── uid2#0.0.3
│ ├── cookie#0.1.0
│ ├── cookie-signature#1.0.1
│ ├── debug#0.7.4
│ ├── fresh#0.2.0
│ ├── merge-descriptors#0.0.1
│ ├── methods#0.1.0
│ ├── mkdirp#0.3.5
│ ├── range-parser#0.0.4
│ └─┬ send#0.1.4
│ └── mime#1.2.11
├── htmldec#0.0.1
├── memwatch#0.2.2
├─┬ morgan#1.0.0
│ └── bytes#0.2.1
├─┬ nodemailer#0.5.5
│ ├─┬ mailcomposer#0.2.6
│ │ ├── dkim-signer#0.1.0
│ │ ├── he#0.3.6
│ │ ├── mime#1.2.9
│ │ ├─┬ mimelib#0.2.14
│ │ │ ├── addressparser#0.2.0
│ │ │ └─┬ encoding#0.1.7
│ │ │ └── iconv-lite#0.2.11
│ │ └── punycode#1.2.3
│ └─┬ simplesmtp#0.3.16
│ ├── rai#0.1.8
│ └── xoauth2#0.1.8
├─┬ nodetime#0.8.14
│ └─┬ nodetime-native#0.1.0
│ └── bindings#1.1.1
├─┬ passport#0.1.17
│ ├── pause#0.0.1
│ └── pkginfo#0.2.3
├─┬ passport-local#0.1.6
│ └── pkginfo#0.2.3
├─┬ request#2.27.0
│ ├── aws-sign#0.3.0
│ ├── cookie-jar#0.3.0
│ ├── forever-agent#0.5.0
│ ├─┬ form-data#0.1.2
│ │ └─┬ combined-stream#0.0.4
│ │ └── delayed-stream#0.0.5
│ ├─┬ hawk#1.0.0
│ │ ├── boom#0.4.2
│ │ ├── cryptiles#0.2.2
│ │ ├── hoek#0.9.1
│ │ └── sntp#0.2.4
│ ├─┬ http-signature#0.10.0
│ │ ├── asn1#0.1.11
│ │ ├── assert-plus#0.1.2
│ │ └── ctype#0.5.2
│ ├── json-stringify-safe#5.0.0
│ ├── mime#1.2.11
│ ├── node-uuid#1.4.1
│ ├── oauth-sign#0.3.0
│ ├── qs#0.6.6
│ └── tunnel-agent#0.3.0
├─┬ sanitize-html#0.1.4
│ ├─┬ htmlparser2#3.3.0
│ │ ├── domelementtype#1.1.1
│ │ ├── domhandler#2.1.0
│ │ ├── domutils#1.1.6
│ │ └── readable-stream#1.0.17
│ └── lodash#1.3.1
└─┬ xml2js#0.2.8
└── sax#0.5.7
This is probably a case issue. Javascript property names are case sensitive.
I think content-length should be Content-Length
referer is spelled wrongly. So you can try Referer and referer.

NodeJS: Express 3.0 with connect-flash( as advised in the passport local strategy), still finding exception for req.flash

I'm new to NodeJS and trying to build an app over Express3.0, included passport local strategy for authentication purpose. But the following exception(with respect to req.flash) blocks my progress.
Exception occurs in the following line.
res.render('login', { user: req.user, message: req.flash('error') });
Express
500 TypeError: Object # has no method 'flash'
at /Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/app.js:115:54
at callbacks (/Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/lib/router/index.js:162:37)
at param (/Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/lib/router/index.js:136:11)
at pass (/Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/lib/router/index.js:143:5)
at Router._dispatch (/Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/lib/router/index.js:171:5)
at Object.router (/Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/lib/router/index.js:33:10)
at next (/Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at store.get.next (/Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/node_modules/connect/lib/middleware/session.js:310:9)
at /Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/node_modules/connect/lib/middleware/session.js:333:9
at /Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/node_modules/connect/lib/middleware/session/memory.js:52:9
I have installed connect-flash to recover the deprecated req.flash method as advised by the author(passport-local-strategy). Please find the npm packages installed in the app.
├── connect-flash#0.1.0
├── ejs#0.8.3
├── ejs-locals#0.2.5
├─┬ express#3.0.0
│ ├── commander#0.6.1
│ ├─┬ connect#2.6.0
│ │ ├── bytes#0.1.0
│ │ ├── formidable#1.0.11
│ │ ├── pause#0.0.1
│ │ ├── qs#0.5.1
│ │ └─┬ send#0.0.4
│ │ └── mime#1.2.6
│ ├── cookie#0.0.4
│ ├── crc#0.2.0
│ ├── debug#0.7.0
│ ├── fresh#0.1.0
│ ├── methods#0.0.1
│ ├── mkdirp#0.3.3
│ ├── range-parser#0.0.4
│ └─┬ send#0.1.0
│ └── mime#1.2.6
├─┬ passport#0.1.12
│ └── pkginfo#0.2.3
├─┬ passport-local#0.1.6
│ ├── passport#0.1.12
│ └── pkginfo#0.2.3
├─┬ socket.io#0.9.10
│ ├── policyfile#0.0.4
│ ├── redis#0.7.2
│ └─┬ socket.io-client#0.9.10
│ ├─┬ active-x-obfuscator#0.0.1
│ │ └── zeparser#0.0.5
│ ├── uglify-js#1.2.5
│ ├─┬ ws#0.4.22
│ │ ├── commander#0.6.1
│ │ ├── options#0.0.3
│ │ └── tinycolor#0.0.1
│ └── xmlhttprequest#1.4.2
└─┬ stylus#0.30.1
├── cssom#0.2.5
├── debug#0.7.0
└── mkdirp#0.3.4
Try adding this to your main app.configure method
app.use(flash());
npm install connect-flash --save
var flash = require('connect-flash')
app.use(flash());
You're using it wrong I think. You just have to call req.flash() with type and message before res.redirect
req.flash('info', 'Welcome to the site, a welcome email has been sent to you.');
res.redirect('/');

Error: connect ECONNREFUSED for Node.js and socket.io application? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
ECONNREFUSED on Port 80
Up until today, my app was working, but then all of a sudden it stopped: it started throwing these errors every time I try to connect to the socket.io-enabled part of the app.
Error: connect ECONNREFUSED
at errnoException (net.js:670:11)
at Object.afterConnect [as oncomplete] (net.js:661:19)
Here are my module version numbers.
CompassionPit#0.5.2 /opt/chat
├── async#0.1.18
├── colors#0.6.0-1
├─┬ connect#2.0.2
│ ├── debug#0.7.0
│ ├── formidable#1.0.9
│ ├── mime#1.2.4
│ └── qs#0.4.2
├── date-utils#1.2.9
├─┬ ecstatic#0.1.6
│ ├── ent#0.0.4
│ └── mime#1.2.5
├─┬ express#2.5.8
│ ├─┬ connect#1.8.7
│ │ ├── formidable#1.0.11
│ │ ├── mime#1.2.5
│ │ └── qs#0.5.0
│ ├── mime#1.2.4
│ ├── mkdirp#0.3.0
│ └── qs#0.4.2
├─┬ flatiron#0.1.17
│ ├─┬ broadway#0.1.15
│ │ ├─┬ cliff#0.1.7
│ │ │ └── eyes#0.1.7
│ │ ├── eventemitter2#0.4.9
│ │ ├─┬ nconf#0.5.1
│ │ │ ├── async#0.1.22
│ │ │ ├── ini#1.0.2
│ │ │ └─┬ optimist#0.3.4
│ │ │ └── wordwrap#0.0.2
│ │ ├─┬ optimist#0.3.1
│ │ │ └── wordwrap#0.0.2
│ │ ├─┬ utile#0.0.10
│ │ │ ├── async#0.1.22
│ │ │ ├── mkdirp#0.3.3
│ │ │ ├── ncp#0.2.6
│ │ │ └── rimraf#1.0.9
│ │ └─┬ winston#0.5.11
│ │ ├── async#0.1.22
│ │ ├── eyes#0.1.7
│ │ ├─┬ loggly#0.3.11
│ │ │ ├── request#2.9.202
│ │ │ └── timespan#2.2.0
│ │ └── stack-trace#0.0.6
│ ├── director#1.0.10
│ ├─┬ optimist#0.3.4
│ │ └── wordwrap#0.0.2
│ ├── pkginfo#0.2.3
│ └─┬ prompt#0.1.12
│ ├── async#0.1.22
│ └─┬ winston#0.5.11
│ ├── async#0.1.22
│ ├── eyes#0.1.7
│ ├─┬ loggly#0.3.11
│ │ ├── request#2.9.202
│ │ └── timespan#2.2.0
│ └── stack-trace#0.0.6
├── geoip#0.4.5
├── hashlib2#1.0.3
├── http-digest#v0.1.0
├─┬ jade#0.20.3
│ ├── commander#0.5.2
│ └── mkdirp#0.3.3
├── marked#0.2.1
├─┬ mongoose#2.5.10
│ ├── hooks#0.2.0
│ └── mongodb#0.9.9-4
├─┬ mysql#0.9.5
│ └─┬ hashish#0.0.4
│ └── traverse#0.6.1
├── nave#0.2.13 extraneous
├─┬ optimist#0.2.8
│ └── wordwrap#0.0.2
├── request#2.1.1
├─┬ socket.io#0.9.0
│ ├── policyfile#0.0.4
│ ├── redis#0.6.7
│ └─┬ socket.io-client#0.9.0
│ ├─┬ ws#0.4.0
│ │ ├── commander#0.5.0
│ │ └── options#0.0.3
│ └── xmlhttprequest#1.2.2
├── sqwish#0.2.0
├── uglify-js#1.2.5
├── underscore#1.3.1
├─┬ union#0.1.8
│ ├── pkginfo#0.2.3
│ └── qs#0.3.2
└─┬ vows#0.5.13
└── eyes#0.1.7
Are you allowing NodeJS to run on port 80? If not you might want to take a look at this: Node.js: ECONNREFUSED on Port 80

Resources