javascript-Node.js应用程序,Express和Cloud Foundry
作者:互联网
我正在使用开箱即用的expressjs应用程序,并且正在使用节点0.8.2.在本地运行良好,但是当我推送到Cloud Foundry时,出现以下错误,并且我不知道从哪里开始调试.我假设这是由配置问题或依赖性问题引起的,但我不知道该怎么办.
表达
500 TypeError:对象#没有方法’randomBytes’
在Object.uid(/var/vcap/data/dea/apps/dwgapp1-0-690016dc6c7142f385b44b144d3d380e/app/node_modules/express/node_modules/connect/lib/utils.js:122:17)
在MemoryStore.generate(/var/vcap/data/dea/apps/dwgapp1-0-690016dc6c7142f385b44b144d3d380e/app/node_modules/express/node_modules/connect/lib/middleware/session.js:203:27)
在生成时(/var/vcap/data/dea/apps/dwgapp1-0-690016dc6c7142f385b44b144d3d380e/app/node_modules/express/node_modules/connect/lib/middleware/session.js:281:13)
在Object.session [作为句柄](/var/vcap/data/dea/apps/dwgapp1-0-690016dc6c7142f385b44b144d3d380e/app/node_modules/express/node_modules/connect/lib/middleware/session.js:290:7)
在下一个(/var/vcap/data/dea/apps/dwgapp1-0-690016dc6c7142f385b44b144d3d380e/app/node_modules/express/node_modules/connect/lib/proto.js:190:15)
在Object.cookieParser [作为句柄](/var/vcap/data/dea/apps/dwgapp1-0-690016dc6c7142f385b44b144d3d380e/app/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js:60:5)
在下一个(/var/vcap/data/dea/apps/dwgapp1-0-690016dc6c7142f385b44b144d3d380e/app/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at Object.methodOverride [as handle](/var/vcap/data/dea/apps/dwgapp1-0-690016dc6c7142f385b44b144d3d380e/app/node_modules/express/node_modules/connect/lib/middleware/methodOverride.js:37:5)
在下一个(/var/vcap/data/dea/apps/dwgapp1-0-690016dc6c7142f385b44b144d3d380e/app/node_modules/express/node_modules/connect/lib/proto.js:190:15)
在多部分(/var/vcap/data/dea/apps/dwgapp1-0-690016dc6c7142f385b44b144d3d380e/app/node_modules/express/node_modules/connect/lib/middleware/multipart.js:62:61)
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, http = require('http')
, path = require('path');
var app = express();
app.configure(function(){
app.set('port', process.env.VCAP_APP_PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('your secret here'));
app.use(express.session());
app.use(app.router);
app.use(require('stylus').middleware(__dirname + '/public'));
app.use(express.static(path.join(__dirname, 'public')));
});
app.configure('development', function(){
app.use(express.errorHandler());
});
app.get('/', routes.index);
app.get('/users', user.list);
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
解决方法:
看来此问题是由连接(表达的依赖项)引起的.我最初使用在节点0.8.8上运行的express创建了我的应用,而CF使用的是0.8.2.即使我在本地似乎没有什么不同,但是当我部署到Cloud Foundry时却遇到了此错误.
我创建了一个全新的应用程序,从一开始就运行Node 0.8.2.这似乎解决了这个问题.
标签:cloudfoundry,node-js,express,javascript 来源: https://codeday.me/bug/20191031/1978749.html