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

JavaScript Node.js Basics 2017 Handling Errors in Node Organizing Your Code with require

shirshah sahel
shirshah sahel
10,035 Points

I'm having a little trouble with organizing my code with require.

After adding profile.js something is not working properly. I am going to attach my workspace. Thanks for consideration.

https://w.trhou.se/h33cxlhl1t

4 Answers

Neil McPartlin
Neil McPartlin
14,662 Points

You were very close. The clue is in the console error message...

treehouse:~/workspace$ node app.js                                                                                                              
/home/treehouse/workspace/app.js:6                                                                                                              
users.forEach(Profile.get);                                                                                                                     
              ^                                                                                                                                 

ReferenceError: Profile is not defined

'Profile' is not recognised but the word 'profile' is expected. The little ' ^ ' is pointing out the problem. Just replace 'P' with 'p'.

shirshah sahel
shirshah sahel
10,035 Points

https://w.trhou.se/6dun89f45p Thanks for that recommendation Neil. However I still have the issue , I have changed the upper P to lower but still didn't work.

users.forEach(profile.get);

Neil McPartlin
Neil McPartlin
14,662 Points

Hi Shirshah. This new Saturday 'snapshot' is not the one you posted on Thursday. It's from a workspace you were working on a few lessons earlier. To get this snapshot working, you just need to fix a few typos in app.js

Line 25:

//Replace
printMessage(username, profile.badges.lenght, profile.points.javascript);
//With
printMessage(username, profile.badges.length, profile.points.JavaScript);

Line 33:

//Comment out this person as their profile cannot be found.
//Replace
getProfile("alenahollingan");
//With
//getProfile("alenahollingan");
shirshah sahel
shirshah sahel
10,035 Points

Thank you Neil for your time, Got it now.