The main issue of installing Express + Stylus (getting ENOENT)

UPDATE: after updating stylus 0.7.4 and expression 2.3.12, I can no longer reproduce this. Presumably, this was a mistake somewhere in an earlier version of the stylus.

I am trying to connect to the simplest express + stylus program. I want screen.styl to be displayed in css and returned in response to GET processing for /screen.css.

I was debugging in the stylus middleware, and the debugger jumps to where I cannot follow. The stylus middleware code looks fine, but GET /screen.css results in Error: ENOENT, No such file or directory '/Users/plyons/projects/test_stylus/screen.css' in response.

I have a test directory with two files (the server is in coffeescript, but this is trivial).

 screen.styl server.coffee 

cat server.coffee

 express = require 'express' app = express.createServer() app.use require('stylus').middleware(__dirname) app.use express.static __dirname app.listen 9800 

cat screen.styl

 a background-color red 

From looking at the stylus middleware.js file for quite some time, I think this should work. The stylus middleware certainly executes and tries to make fs.stat both the fs.stat file that exists and the .css file that does not exist yet, so ENOENT but the middleware looks as if it should detect that ENOENT and process it without any problems (compile .styl and save the result in .css). But the .css file is not written. If this was written, the system is designed for middleware to call next() without actually sending anything in the response, but then the static limit will find the .css file and send it as an answer, right?

Does anyone know what I'm wrong here?

+4
source share
1 answer

UPDATE: after updating stylus 0.7.4 and expression 2.3.12, I can no longer reproduce this. Presumably, this was a mistake somewhere in an earlier version of the stylus.

+1
source

All Articles