how to set path to the views (template) directory and to static files in node.js

I have created layout.jade, navigation.jade, and index.jade, and I want to glue them together.

In server.js, how do I

  1. set the path to the views (template) directory, and
  2. set the path to static files.

Is it required that node_module be placed in the folder that contains server.js?

Below is the code for server.js:

//create an app server
var express = require("express");
var server = express.createServer();

//set path to the views (template) directory
app.set('views', D:\#Programming\node.js\trial box\views);

//set path to static files
//how is the path to static files set?
app.use(express.static(__dirname + '/../public'));

//handle GET requests on /
app.get('/', function(req, res){
    res.render('index.jade', {title: 'web project'});
});

//listen on localhost:3000
app.listen(3000);

Thank you in advance.

This questions a little old, but I'll still leave an answer. You'll need to place your app.use(... statement inside a callback function for app.configure() like so..

app.configure(function(){
  app.use(express.static(__dirname + '/../public'));
});

You should use the express bin tool to bootstrap a project you'd get all that setup. To install it:

sudo npm install express -g