Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Build a Simple Dynamic Site with Node.js Handling Routes in Node.js Populating User Information

Carlos Sanchez
Carlos Sanchez
8,900 Points

Error when creating a new Person()

Getting the following error when i enter a username in the browser:

var studentProfile = new Profile(username);

ReferenceError: Profile is not defined
at Object.user (/home/treehouse/workspace/router.js:18:32)
at Server.<anonymous> (/home/treehouse/workspace/app.js:6:11)
at emitTwo (events.js:106:13)
at Server.emit (events.js:191:7)
at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:543:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:105:23)
This is my workspace: https://w.trhou.se/tzqxwjju5a Does anyone know why is this happening?

2 Answers

Benjamin Barslev Nielsen
Benjamin Barslev Nielsen
18,958 Points

You are very close.

Line 1 in router.js:

var profile = require("./profile.js");

should be

var Profile = require("./profile.js");

and line 20 in router.js:


should be

Rodrigo Valladares
Rodrigo Valladares
9,708 Points

Wooo! thanks, I've had the same mistake!!

Carlos Sanchez
Carlos Sanchez
8,900 Points

Thanks, that solved it for me. I am new to this perspective, coming from java servlets and spring node is proving to be something else. Thank you now I can move forward with the course.