Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap LESS with Node.js & Express

Tags:

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 undefined 

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?

like image 436
Patrick Avatar asked Feb 07 '12 09:02

Patrick


People also ask

Can you use less with Bootstrap?

Less is a CSS preprocessor which makes CSS dynamic. Twitter Bootstrap, on the other hand, is a toolkit to develop web apps and sites fast. In this document, we have discussed using Twitter Bootstrap with Less CSS. This way you can use Bootstrap's Less variables, mixins, and nesting in CSS.

Can you use Bootstrap with Nodejs?

In this article, we learned how to integrate Bootstrap into our Nodejs project in two different ways. The first way is to use official CDN , the second way is to use npm . This last solution is suitable if you're working locally (and offline). Ace your System Design Interview and take your career to the next level.

Is Twitter Bootstrap responsive?

With Bootstrap 2, we've gone fully responsive. Our components are scaled according to a range of resolutions and devices to provide a consistent experience, no matter what.

Does twitter use Bootstrap?

At Twitter, Bootstrap has quickly become one of our many go-to front-end tools when starting new applications and sites.


1 Answers

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 app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(app.router); 
like image 69
GoldenBoy Avatar answered Sep 18 '22 06:09

GoldenBoy