Reputation: 1904
I'm new to node js and express. I installed express-mailer using npm with no problems. From the (mac) command line I generated an express (4.13.1) app with "express". Per the github instructions I modified app.js and changed:
var express = require('express');
to
var express = require('express')(),
mailer = require('express-mailer');`
but then "node start" crashes with:
/Users/gary/mailertest/node_modules/express/node_modules/finalhandler/index.js:58
var status = res.statusCode
^
TypeError: Cannot read property 'statusCode' of undefined`
I launch a node session and I know the var express = ...
succeeds. The line that fails is the subsequent:
var app = express();
I definitely don't understand all the pieces here so I'm not sure how to continue troubleshooting this.
Upvotes: 0
Views: 1031
Reputation: 9136
From what I read from your code description:
var express = require('express')(), mailer=require('express-mailer'); //.. some code here var app = express();
You should not instantiate two times express, instead you should instantiate express once:
var express = require('express'), //.. some code here var app = express(); var mailer = require('express-mailer');
So even after you run successfully your example, bear in mind about what it says in node-mailers documentation:
Works with Express 3.x.x
And you are working with the express version 4.x, so not sure if this express-mailer library may have some issues with this aspect of express version.
Upvotes: 1