2013-08-01 157 views
0

我刚开始使用节点,我试图用一个快速的玉石和手写笔包来运行它。我想我已经正确设置了,但是CSS文件没有被编译,并且当样式表的请求发生时,我仍然收到404未找到的响应。手写笔不编译样式表(nodejs表示手写笔和笔尖)

这里是我的服务器

/* 
    * Module dependencies 
    */ 
var express = require('express'), 
    stylus = require('stylus'), 
    nib = require('nib'); 
    var app = express(); 

function compile(str, path) { 
    return stylus(str) 
     .set('filename', path) 
     .use(nib()); 
} 
app.set('views', __dirname + '/views'); 
app.set('view engine', 'jade'); 
app.use(express.logger('dev')); 
app.use(stylus.middleware({ 
src: __dirname + '/public/stylesheets', 
compile: compile 
})); 

app.use(express.static(__dirname + '/public')); 

/* Routes */ 

app.get('/', function (req, res) { 
res.render('index', 
    { title : 'Home' } 
) 
}) 


/* Start the server */ 

app.listen(3000); 

console.log('listening on port 3000'); 

和我layout.jade文件

!!!5 
html 
head 
    title #{title} - My Site 
    link(rel='stylesheet', href='stylesheets/style.css') 
body 
    header 
    h1 My Site 
    .container 
    .main-content 
     block content 
    .sidebar 
    block sidebar 
    footer 
    p Running on node with Express, Jade and Stylus 

回答