When i am hosting my node app on heroku i am getting the following error.

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)
at generate (/app/node_modules/express/node_modules/connect/lib/middleware/session.js:288:13)
at Object.session [as handle] (/app/node_modules/express/node_modules/connect/lib/middleware/session.js:297:7)
at next (/app/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at Object.cookieParser [as handle] (/app/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js:60:5)
at next (/app/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at Object.expressInit [as handle] (/app/node_modules/express/lib/middleware.js:31:5)
at next (/app/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at Object.query [as handle] (/app/node_modules/express/node_modules/connect/lib/middleware/query.js:44:5)

I tried to remove lines one by one and get to this where i removed

app.use(express.session({ secret:'yodawgyo' }));

The app was giving the "Hello World" response.
See my complete code below.

1 Answer
1

I was having the same issue. It was resolved by adding the "engines" block to package.json which directs Heroku to use a specific version of node and npm. Most likely you are using a much newer version of node than the Heroku default 0.4.7