Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Twitter Bootstrap LESS with Node.js & Express

Twitter Bootstrap LESS with Node.js & Express


Since Twitter Bootstrap 2 is out, I wanted to integrate that into my Node.js project. Unfortunately, there's something wrong with the less compiler and I can't get it to work. I put all files into the public folder and set up a new project with express -c less newproj. and added the lines for less

less = require('less');
app.use(express.compiler({ src: __dirname + '/public', enable: ['less'] }));

All Node tells me is:

Express server listening on port 3000 in development mode

On the client side I get a 500 (Internal Server Error) for the bootstrap.css file, which should be compiled by lessc.

lessc bootstrap.less

Works fine.

Anybody knows how to solve the issue?

Problem courtesy of: Patrick


For posterity, this has changed a lot in recent Express:

app.use(require('less-middleware')({ src: __dirname + '/public' }));
app.use(express.static(path.join(__dirname, 'public')));

// This is just boilerplate you should already have
Solution courtesy of: GoldenBoy


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Twitter Bootstrap LESS with Node.js & Express


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription