Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8382239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:53:04+00:00 2026-06-09T16:53:04+00:00

I had set up compiling LESS on server side in Express, and it worked

  • 0

I had set up compiling LESS on server side in Express, and it worked right in jade without putting less in layout.

my terminal:

if(err) throw err;
                ^
Error: ENOENT, open '/Users/lijung/Documents/Project/clubond/public/stylesheets/left_navigator.less'

app.js:

/**
 * Module dependencies.
 */

var express = require('express')
    , path = require('path')
    , club = require('./routes/club')
    , less = require('less')
    , fs = require('fs');

var app = module.exports = express.createServer();

// Configuration

app.configure(function(){
    var RedisStore = require('connect-redis')(express);
    app.use(express.cookieParser());
    app.use(express.session({ secret: "william", store: new RedisStore }));
    app.use(express.logger());
    app.set('views', __dirname + '/views');
    app.set('view engine', 'jade');
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(app.router);
    app.set('view options', { layout: false });
    app.use(express.static(path.join(__dirname, 'public')));
});


app.configure('development', function(){
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});

app.configure('production', function(){
    app.use(express.errorHandler()); 
});

// Routes
//index-in-layout
app.get('/club/:id', club.chkExist, club.getDataById, site.clubPage);

//compile less
app.get("*.less", function(req, res) {
    var path = __dirname + req.url;
    fs.readFile(path, "utf8", function(err, data) {
        if(err) throw err;
        less.render(data, function(err, css) {
    if (err) throw err;
        res.header("Content-type", "text/css");
        res.send(css);
     });
   });
}); 


app.listen(3000);
console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);  

I put my layout in views named index_in_layout:

!!! 5
html
head
    title= title
    script(src='/javascripts/jquery.min.js')
    link(rel="stylesheet", href="/stylesheets/index.css")
    link(rel="stylesheet",type='text/css', href="/public/stylesheets/left_navigator.less")
    script(src='/javascripts/index_in.js')
    block script
body

index.jade:

extends ./index_in_layout

block script

    script(src='/javascripts/new_club.js')
    script(src='/javascripts/new_bond.js')
    script(src='/javascripts/new_event.js')
    script(src='/javascripts/popup.js')
    script(src='/javascripts/list_clubs.js')
    script(src='/javascripts/list_bonds.js')
    script(src='/javascripts/list_events.js')
    link(rel='stylesheet', type='text/css', href='/public/stylesheets/test.less')


block body  

Terminal keeps telling me Error: ENOENT that my left_navigator.less can’t open. I put test.less and navigator.less in the same directory, it makes no sense.

LESS on server side driving me crazy. Can someone help me out please. Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:53:06+00:00Added an answer on June 9, 2026 at 4:53 pm

    Unless I’m missing something, you really don’t need to go through these heroics to get less working 🙂 Generally you just need to add one line to your app.configure call like this:

    app.configure(function() {
        app.set('views', __dirname + '/views');
        ...
        app.use(express.compiler({ src: __dirname + '/public', enable: ['less'] }));
        app.use(connect.static(__dirname + '/public'));
        app.use(app.router);
    });
    

    If you do it this way, you don’t need the special route for *.less files. You just request *.css with the same name in your public folder and it’s automatically generated. I use master/child layouts with jade and LESS here if an example would help:

    https://github.com/JustinBeckwith/ExpressStarter

    Happy Coding!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had set up a bunch of NUnit unit tests using the Test connection
I had set up the MvcBuildViews element to true so my MVC 3 project
I've been developing a project on my local machine and had set up a
1)I had a set of .js files in a particular Directory structure. 2)I NEED
Due to some rather bizarre architectural considerations I've had to set up something that
When I looked at: http://replicaisland.googlecode.com/svn/trunk/res/drawable/ and found it only had one set of images,
I had a problem with set not working in a batch file; it took
If you had two snippets: (global-set-key \C-d delete-char) and (define-key global-map \C-d delete-char) Is
If a set of controls on a WinForm have had DataBindings created and attached
Currently I had 2 different schema set (setA/ and setB/) sitting under multicore/ folder

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.