You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//create node.js http server and listen on port
http.createServer(app).listen(3000);
function server(res,path, type){
res.writeHead(200,{'Coent-Type':type});
fs.createReadStream(path).pipe(res);
}
when run node, the error found:
E:\eclipse42_wk\nodeconn\src\node_modules\connect-logger\lib\logger.js:13
format = format.replace(/%date/g, "\x1b[90m" + (moment().format(options.da
^
TypeError: Cannot call method 'replace' of undefined
at parse (E:\eclipse42_wk\nodeconn\src\node_modules\connect-logger\lib\logge
r.js:13:21)
at ServerResponse.res.end (E:\eclipse42_wk\nodeconn\src\node_modules\connect
-logger\lib\logger.js:41:17)
at ReadStream.onend (_stream_readable.js:485:10)
at ReadStream.g (events.js:180:16)
at ReadStream.emit (events.js:117:20)
at _stream_readable.js:929:16
at process._tickCallback (node.js:419:13)
The text was updated successfully, but these errors were encountered:
I've a js file as following:
var connect = require('connect');
var http = require('http');
var fs=require('fs');
var app = connect();
// gzip/deflate outgoing responses
var compression = require('compression');
app.use(compression());
// store session state in browser cookie
var cookieSession = require('cookie-session');
app.use(cookieSession({
keys: ['secret1', 'secret2']
}))
// parse urlencoded request bodies into req.body
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded());
var logger= require('connect-logger');
app.use(logger('short'));
app.use(function(req,res,next){
console.error('%s %s', req.method, req.url);
next();
});
app.use(function(req, res,next){
if('GET'==req.method && '/'==req.url){
server(res,__dirname+'/index.html', 'text/html');
}
else{
next();
}
});
app.use(function(req, res ,next){
});
app.use(function(req, res ,next){
});
//create node.js http server and listen on port
http.createServer(app).listen(3000);
function server(res,path, type){
res.writeHead(200,{'Coent-Type':type});
fs.createReadStream(path).pipe(res);
}
when run node, the error found:
E:\eclipse42_wk\nodeconn\src\node_modules\connect-logger\lib\logger.js:13
format = format.replace(/%date/g, "\x1b[90m" + (moment().format(options.da
^
TypeError: Cannot call method 'replace' of undefined
at parse (E:\eclipse42_wk\nodeconn\src\node_modules\connect-logger\lib\logge
r.js:13:21)
at ServerResponse.res.end (E:\eclipse42_wk\nodeconn\src\node_modules\connect
-logger\lib\logger.js:41:17)
at ReadStream.onend (_stream_readable.js:485:10)
at ReadStream.g (events.js:180:16)
at ReadStream.emit (events.js:117:20)
at _stream_readable.js:929:16
at process._tickCallback (node.js:419:13)
The text was updated successfully, but these errors were encountered: