我在heroku上運行Expressjs安裝,它不加載樣式表。Expressjs不加載在heroku樣式表,給500錯誤
我按Ctrl + U,然後單擊樣式錶鏈接,出現此錯誤:
TypeError: Object #<SendStream> has no method 'on'
at Object.static [as handle] (/app/node_modules/express/node_modules/connect/lib/middleware/static.js:75:8)
at next (/app/node_modules/express/node_modules/connect/lib/proto.js:190:15)
當我去「/stylesheets/style.css」的網址我得到這個錯誤:
Express
500 TypeError: Object #<SendStream> has no method 'on'
at Object.static [as handle] (/app/node_modules/express/node_modules/connect/lib/middleware/static.js:75:8)
at next (/app/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at /app/node_modules/stylus/lib/middleware.js:174:46
at /app/node_modules/stylus/lib/middleware.js:208:20
一切工作正常本地。
這裏是的package.json
{
"name": "app-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app"
},
"dependencies": {
"express": "3.0.0rc1",
"jade": "*",
"stylus": "*"
}
}
的app.js:
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, http = require('http')
, path = require('path');
var app = express();
app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
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('/about', routes.about);
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
的Procfile:
web: node app.js
如果我保持清爽,它崩潰的應用程序。
謝謝,這對我很有用! – 2012-08-27 21:20:48
任何人都可以澄清爲什麼指定節點/ npm引擎版本解決了在快速靜態內容請求失敗的問題? 我投了票,因爲它爲我工作,但這有點莫名其妙?! – warriorpostman 2012-11-28 19:35:14
我假設它默認使用錯誤的? ...比我多一點知識的人應該編輯我的答案,使其明確。 – silasjmatson 2012-11-28 19:44:22