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

node.js+express+jade: style.css internal server error 500

node.js+express+jade: style.css internal server error 500

Problem

I have a problem with node.js+express+jade that I don't know how to resolve, I have already searched on google and stackoverflow with no solution, so I ask to you to help me please :)

The problem is that all works except for style.css:

Failed to load resource: the server responded with a status of 500 (Internal 
 Server Error)

P.S: i have reinstalled latest versions of node.js and modules for security, without solution

UPDATE:the error outs ONLY when I add this: link(rel='stylesheet', href='style.css') in the jade file

app.js

var express = require("express"); 
app = express(),
routes = require('./routes');

app.configure(function(){
    app.set('port', 8080);
    app.set('views', __dirname + '/views');
    app.set('view engine', 'jade');
    app.use(express.favicon());
    app.use(express.logger('dev'));
    app.use(express.urlencoded());
    app.use(express.methodOverride());
    app.use(app.router);
    app.use(express.static(__dirname + '/public'));
});

app.get("/", routes.index);

app.listen(app.get("port"), function() {
    console.log("App listening on port " + app.get("port"));
});

routes/index.js

exports.index = function(req, res) {
    res.render('index');
};

public/style.css

body {
    font-size: 20px;
}

i have got this error:

my_path_privacy\nodejs-test>node app.js
    App listening on port 8080
    ←[90mGET / ←[32m200 ←[90m3674ms - 867b←[0m
    TypeError: Object # has no method 'on'
        at Object.staticMiddleware [as handle] (my_path_privacy\nodejs-test\node_modules\express\node_modules\connect\lib\middleware\static.js:89:8)
        at next (my_path_privacy\nodejs-test\node_modules\express\node_modules\connect\lib\proto.js:193:15)
        at pass (my_path_privacy\nodejs-test\node_modules\express\lib\router\index.js:110:24)
        at Router._dispatch (my_path_privacy\nodejs-test\node_modules\express\lib\router\index.js:173:4)
        at Object.router [as handle] (my_path_privacy\nodejs-test\node_modules\express\lib\router\index.js:33:10)
        at next (my_path_privacy\nodejs-test\node_modules\express\node_modules\connect\lib\proto.js:193:15)
        at Object.methodOverride [as handle] (my_path_privacy\nodejs-test\node_modules\express\node_modules\connect\lib\middleware\methodOverride.js:48:5)
        at next (my_path_privacy\nodejs-test\node_modules\express\node_modules\connect\lib\proto.js:193:15)
        at Object.urlencoded [as handle] (my_path_privacy\nodejs-test\node_modules\express\node_modules\connect\lib\middleware\urlencoded.js:41:37)
        at next (my_path_privacy\nodejs-test\node_modules\express\node_modules\connect\lib\proto.js:193:15)
    ←[90mGET /style.css ←[31m500 ←[90m52ms - 1.34kb←[0m

package.json

{
   "name": "app-test",
   "version": "0.0.1",
   "private": true,
   "scripts": {
       "start": "node app.js"
   },
   "dependencies": {
      "express": "3.4.7",
      "jade": "1.1.0"
   },
   "engines": {
      "node": "0.10.24",
      "npm": "1.3.21"
  }
}

index.jade

doctype html
html
  head
    title Hello world
    link(rel='stylesheet', href='style.css')
  body
    p Hello world
Problem courtesy of: Manuel Di Iorio

Solution

The solution ?
Because the problem was express and not jade, I made a framework myself with same features of express but a lot of lightweight and only the necessary for a complete website management and the best thing, no bugs baby :)

Thank you for all your answers and your patience with a new entry in node.js =D

Solution courtesy of: Manuel Di Iorio

Discussion

View additional discussion.



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

Share the post

node.js+express+jade: style.css internal server error 500

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×