I'm running an Expressjs installation on heroku, and it's not loading the stylesheets.
I hit ctrl+u and then click on the stylesheet link, and get this error:
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)
When I go to the url '/stylesheets/style.css' I get this error:
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
Everything works fine locally.
here is the package.json
{
"name": "app-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app"
},
"dependencies": {
"express": "3.0.0rc1",
"jade": "*",
"stylus": "*"
}
}
The 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'));
});
The Procfile:
web: node app.js
If I keep refreshing, it crashes the app.
I was able to solve this by specifying the engine dependencies in the package.json
{
"name": "app-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app"
},
"dependencies": {
"express": "3.0.0rc1",
"jade": "*",
"stylus": "*"
},
"engines": {
"node": "0.8.4",
"npm": "1.1.41"
}
}
I found the answer! you got a wrong runtime of the application push to the cloud you can do this
vmc push yourappname --runtime node08
i hope i can help you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With