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


Error of express(Node.js)

When I'm trying to start Node.js app(CodeRacer Day1), i'm getting error: server.coffee:1:1: error: reserved word "var" var express = require('express'); ^I little bit changed code of server.coffee. Here is it: var express = require('express'); var app = express();

app.get('/', function(req, res){ res.send('hello world'); });

app.listen(3000); console.log "Server is listening";

1 Answer

Nick Stellato
Nick Stellato
Front End Web Development Techdegree Student 33,994 Points

Coffee script does not use the word var when defining variables. It is trying to create a var variable when it converts coffee script into javascript.

Server.coffee should read:

express = require('express')
app = express ()

That will convert into:

var express,

express = require('express');
app = express();