Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Rodrigo Muñoz
Courses Plus Student 20,171 PointsCoderacer: Node is not rendering
I am trying to do the Coderacer example but something is not working very well. I've just started with the first lines of code and installing the packages. Here is the code:
server.coffee
require 'coffee-script'
express = require 'express'
app = express()
app.get '/', (req, res) ->
res.send "Hello from express"
app.listen(3000)
console.log "Server is listening"
index.eco
<!DOCTYPE html>
<html lang="end">
<head>
<title>Our Page</title>
<body>
<h1>Our Index</h1>
</body>
</head>
</html>
First I have to tell that the
express.createServer()
has change to
express()
Well now I am trying to render the index.eco file but is not working by changing
res.send "Hello from express"
to
res.render 'index.eco', layout: false
Any ideas?
2 Answers
Chris Akers
2,527 PointsIt looks like you might simply have a indentation issue. Rather than:
app.get '/', (req, res) ->
res.send "Hello from express"
The second line should be indented further so that coffeescript knows that it's the body of the function:
app.get '/', (req, res) ->
res.send "Hello from express"
Let me know if that helps.
Rodrigo Muñoz
Courses Plus Student 20,171 PointsI have mistake while typing into this post, but now I've fixed. The code in the project have the proper indentation but it's still not working. Now while I came back to sublime text it appear an alert that it's not supporting coffeescript again and the highlight have stoped. Does this have to do with the same problem I have that the res.render() is not working?