我在 heroku 上运行 Expressjs 安装,它没有加载样式表。
我按 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)
当我转到 url '/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'));
});
过程文件:
web: node app.js
如果我继续刷新,它会使应用程序崩溃。