title: Run into a 500 internal server error when loading css and js in express
body: <p>I'm new to NodeJS,tring to replicate the program on the book.
  View engine is jade,and I'm using Bootstrap.The static path is right,I think.</p>
  
  <pre><code>app.use(express.static(__dirname+'/public'));
  </code></pre>
  
  <p>but when I console it,it shows this,</p>
  
  <pre><code>C:\Users\Dell\Desktop\express\microblog/public
  </code></pre>
  
  <p>the problem only shows when I try to visit the page in broswer,not immediately after I actived the server,and the error code is 500, like below,</p>
  
  <pre><code>Cannot read property 'lazyrouter' of undefined
  
  TypeError: Cannot read property 'lazyrouter' of undefined
      at route (C:\Users\Dell\Desktop\express\microblog\node_modules\express\lib\application.js:254:7)
      at Layer.handle [as handle_request] (C:\Users\Dell\Desktop\express\microblog\node_modules\express\lib\router\layer.js:95:5)
      at trim_prefix (C:\Users\Dell\Desktop\express\microblog\node_modules\express\lib\router\index.js:312:13)
      at C:\Users\Dell\Desktop\express\microblog\node_modules\express\lib\router\index.js:280:7
      at Function.process_params (C:\Users\Dell\Desktop\express\microblog\node_modules\express\lib\router\index.js:330:12)
      at next (C:\Users\Dell\Desktop\express\microblog\node_modules\express\lib\router\index.js:271:10)
      at C:\Users\Dell\Desktop\express\microblog\node_modules\express-session\index.js:489:7
      at C:\Users\Dell\Desktop\express\microblog\node_modules\connect-mongo\lib\connect-mongo.js:306:11
      at handleCallback (C:\Users\Dell\Desktop\express\microblog\node_modules\mongodb\lib\utils.js:96:12)
      at C:\Users\Dell\Desktop\express\microblog\node_modules\mongodb\lib\collection.js:1335:5
  </code></pre>
  
  <p>but actually the layout.jade is correctly rendered,only the block content area shows the error. </p>
  
  <p>app.js below</p>
  
  <pre><code>var settings=require('./settings');
  var express = require('express');
  var path = require('path');
  var favicon = require('serve-favicon');
  var logger = require('morgan');
  var cookieParser = require('cookie-parser');
  var bodyParser = require('body-parser');
  var session=require('express-session');
  var MongoStore=require('connect-mongo')(session);
  
  var User=require('./models/user');
  var crypto=require('crypto');
  
  var index = require('./routes/index');
  var users = require('./routes/users');
  var post = require('./routes/post');
  var reg = require('./routes/reg');
  var login = require('./routes/login');
  var logout = require('./routes/logout');
  
  var app = express();
  
  // view engine setup
  app.set('views', path.join(__dirname, 'views'));
  app.set('view engine', 'jade');
  
  // uncomment after placing your favicon in /public
  //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
  app.use(logger('dev'));
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(cookieParser());
  app.use(session({
      secret: settings.cookieSecret,
      resave: false,
      saveUninitialized: true,
      store: new MongoStore({
          db:settings.db
      })
  }));
  app.use(app.route);
  app.use(express.static(path.join(__dirname,'/public')));
  console.log(__dirname+'/public');
  
  
  app.use('/', index);
  app.use('/users', users);
  app.use('/post', post);
  app.use('/reg', reg);
  app.use('/login', login);
  app.use('/logout', logout);
  
  // catch 404 and forward to error handler
  app.use(function(req, res, next) {
    var err = new Error('Not Found');
    err.status = 404;
    next(err);
  });
  
  // error handler
  app.use(function(err, req, res, next) {
    // set locals, only providing error in development
    res.locals.message = err.message;
    res.locals.error = req.app.get('env') === 'development' ? err : {};
  
    // render the error page
    res.status(err.status || 500);
    res.render('error');
  });
  
  app.use(function (req,res,next) {
      res.locals.user=req.session.user;
  
      var err=req.flash('error');
      var success=req.flash('success');
  
      res.locals.err=err.length?err:null;
      res.locals.success=success.length?success:null;
  
      next();
  })
  
  module.exports = app;
  </code></pre>
  
  <p>`
  below is the link part of layout.jade</p>
  
  <pre><code>link(type='text/css',rel='stylesheet', href='/stylesheets/bootstrap.css')
  link(type='text/css',rel='stylesheet', href='/stylesheets/bootstrap-responsive.css')
  script(src="/javascripts/jquery.js")
  script(src="/javascripts/bootstrap.js")
  </code></pre>