azat-co / expressworks

Learn Express.js from the author of one of the best books on Express.js—Pro Express.js— with this workshop that will teach you basics of Express.js.
MIT License
709 stars 220 forks source link

excise 5 STYLISH CSS verify wrong #32

Closed backsapce closed 9 years ago

backsapce commented 9 years ago

i have post the official solution but verify got wrong

$ expressworks verify  expressword.js 
Verifying "STYLISH CSS"...

ACTUAL                             EXPECTED
------                             --------
"Error: EACCES, open '/usr/local/lib/node_modules/expressworks/problems/stylish_css/public/main.css'"    "Error: EACCES, open '/usr/local/lib/node_modules/expressworks/problems/stylish_css/public/main.css'"
""                              != null                           
# FAIL

Your solution to STYLISH CSS didn't match the expected output.
Try again!

the official solution

var app = express()

app.use(require('stylus').middleware(process.argv[3]));
app.use(express.static(process.argv[3]));

app.listen(process.argv[2])
azat-co commented 9 years ago

EACCES? permissions for the css file?

paulodiovani commented 9 years ago

It tries to write on node global expressworks install. So it would work with sudo.

tomppa commented 9 years ago

I got a wrong solution (without the express.static line) to pass, because both are failing similarly. Awkwardness.

~/code/js/expressworks tomppa$ expressworks verify exercise5.js
Verifying "STYLISH CSS"...

ACTUAL                             EXPECTED
------                             --------
"Error: EACCES, open '/usr/local/lib/node_modules/expressworks/problems/stylish_css/public/main.css'"    "Error: EACCES, open '/usr/local/lib/node_modules/expressworks/problems/stylish_css/public/main.css'"
# PASS

Your solution to STYLISH CSS passed!

vs.

~/code/js/expressworks tomppa$ sudo expressworks verify exercise5.js
Password:
Verifying "STYLISH CSS"...

ACTUAL                             EXPECTED
------                             --------
"Cannot GET /main.css"          != "p {"                          
""                              != "  color: #f00;"               
null                            != "}"                            
null                            != ""                             
# FAIL

Your solution to STYLISH CSS didn't match the expected output.
Try again!

Oops?

mduleone commented 9 years ago

I ran in to the same problem with this exercise and exercise 6. I just submitted an issue for exercise 6.

Verifying "STYLISH CSS"...

ACTUAL                             EXPECTED
------                             --------
"p {"                           != "Cannot GET /main.css"
"  color: #f00;"                != ""
"}"                             != null
""                              != null
# FAIL
stevemao commented 9 years ago

Same problem here.

jgainfort commented 9 years ago

paulodiovani is correct. Run verify command using sudo.

Example:

$sudo expressworks verify filename.js

Verifying "STYLISH CSS"...

ACTUAL                             EXPECTED
------                             --------
"p {"                              "p {"                          
"  color: #f00;"                   "  color: #f00;"               
"}"                                "}"                            
""                                 ""                             
# PASS
mduleone commented 9 years ago

@jgainfort Check out issue #42. The verify command under sudo doesn't work for me or others. It's not the right solution. On top of that, you shouldn't need sudo access to run through this tutorial

stevemao commented 9 years ago

@mduleone your problem is different from the issue here. It is because npm doesn't have the right to read the provided css, hence sudo can solve the problem. yours is probably related to #30

jrdn91 commented 9 years ago

Any way to get this lesson to pass? I typed the same solution as the one in the solution file for this lesson and even copied that solution to make sure I wasn't missing something and I can't get this to pass. Getting the same error as the OP

aaaaargZombies commented 9 years ago

Sooooooo, my code works when I run it with node and I get the disered response in the browser. Previously I was getting what looked like errors on the 'expected' side of the checker and what looked like the correct answer on mine. Now for some reason the verify part of the program seems to have completely given up on me all I get is this and a blinking cursor in my terminal.

Verifying "STYLISH CSS"...

ACTUAL                             EXPECTED
------                             --------

// blinking cursor of doom.

Perhaps running it as root will give it the push it needs to churn through the test but alas it won't give me the tick on my users account and I wont have that nice complete feeling....

my code below...

var express     = require('express'),
    app         = express(),
    dir         = process.argv[3],
    port        = process.argv[2];

app.use(express.static(dir));
app.use(require('stylus').middleware(dir));

app.listen(Number(port));
aaaaargZombies commented 9 years ago

ok I fixed it.

running my initial code to test it with my browser must have left something using the port expressworks wants, so I did killall node to clear what ever my last program had left floating around. I then got the EACCES error some people are refering to above. I changed the file permisions in the relevant folder,

su -c 'chown GROUP:USR /usr/lib/node_modules/expressworks/problems/stylish_css/public/*' 

which is a bit hacky, I suspect if you installed and ran expressworks locally as described in the README you wouldn't have that problem because you should have all the correct permisions already. neither solution is particually satisfying but atleast it passed the test.

mhurwicz commented 8 years ago

The official solution provided in the first comment works for me now.