Reputation: 18831
I'm trying expose a bower_components
directory on my express app and it keep throwing errors.
TypeError: Object #<ServerResponse> has no method 'static'
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.use("/", app.static(__dirname + "/bower_components"));
app.get('/', function(req, res){
res.sendfile('index.html');
});
io.on('connection', function(socket){
console.log('a user connected');
socket.on('disconnect', function(){
console.log('user disconnected');
});
});
http.listen(3000, function(){
console.log('listening on *: 3000');
});
Upvotes: 1
Views: 50
Reputation: 19573
Express 3's API for this has changed. You need to call express.static()
, not app.static()
.
var express = require('express');
var app = express();
app.use("/", express.static(__dirname + "/bower_components"));
Based on this answer.
Upvotes: 2