我的 node.js 应用程序具有依赖项
{
"name": "application-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app"
},
"dependencies": {
"express": ">=2.2.0",
"jade": "*",
"stylus": "*",
"mongodb": ">= 0.9.6-7"
}
}
它在我的本地主机上运行良好
当我在 heroku 上托管我的节点应用程序时,我收到以下错误。
TypeError: Object # has no method 'randomBytes' at Object.uid (/app/node_modules/express/node_modules/connect/lib/utils.js:121:17) at MemoryStore.generate (/app/node_modules/express/node_modules/ connect/lib/middleware/session.js:204:27) 在生成 (/app/node_modules/express/node_modules/connect/lib/middleware/session.js:288:13) 在 Object.session [作为句柄] (/ app/node_modules/express/node_modules/connect/lib/middleware/session.js:297:7) 在下一个 (/app/node_modules/express/node_modules/connect/lib/proto.js:190:15) 在 Object.cookieParser [作为句柄] (/app/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js:60:5) 在下一个 (/app/node_modules/express/node_modules/connect/lib/proto.js:190: 15) 在 Object.expressInit [作为句柄] (/app/node_modules/express/lib/middleware.js:31:5) 在下一个 (/app/node_modules/express/node_modules/connect/lib/proto.js:190:15) 在 Object.query [作为句柄] (/app/node_modules/express/node_modules/connect/lib/middleware/查询.js:44:5)
我试图一一删除行并到达我删除的位置
app.use(express.session({ secret:'yodawgyo' }));
该应用程序正在给出“Hello World”响应。请参阅下面的完整代码。
var express = require('express');
var crypto = require('crypto');//for gravatar
var passport = require('passport')
, OpenIDStrategy = require('passport-openid').Strategy
, GoogleStrategy = require('passport-google').Strategy
, AOLStrategy = require('passport-aol').Strategy
, YahooStrategy = require('passport-yahoo').Strategy;;
passport.serializeUser(function(user, done) {
done(null, user);
});
passport.deserializeUser(function(obj, done) {
done(null, obj);
});
var app = module.exports = express();
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.cookieParser());
//NO ISSUES WITH HEROKU IF I COMMENTED BELOW LINE
app.use(express.session({ secret:'yodawgyo' }));
app.use(app.router);
});
app.get('/', function(req, res) {
res.send("Hello World");
});
app.listen(process.env.PORT || 5000, function() {
console.log("listening on 5000");
});
请帮帮我。