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

Converting Express 2.x app to Express 3.0 app

Converting Express 2.x app to Express 3.0 app

Problem

I'm currently learning NodeJs and Express am trying to convert a tutorial app from Express 2.5.9 to 3.0. The code below now throws the error "500 Error: Failed to lookup view "views/login". What is the 3.0 way of getting this to render now?

apps
  authentication
    views
      login.jade
    routes.coffee
...
server.js

And in routes.coffee

routes = (app) ->

  app.get '/login', (req, res) ->
    res.render "views/login",
      title: 'Login'
      stylesheet: 'login'

module.exports = routes
Problem courtesy of: basheps

Solution

To find out what directory express is using to find your views you need to check the following setting of your view engine:

app.set('views', __dirname + '/some-dir');

This is something that didn't change in 3.x. If you need further help migrating the following guide might be useful:

https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x

Solution courtesy of: Pickels

Discussion

View additional discussion.



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

Share the post

Converting Express 2.x app to Express 3.0 app

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×