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 trialDaven Hietala
8,040 PointsPractice Object Literals in JavaScript thro err;
I just completed the Object Literal lesson for js. Upon completion I was prompted to practice what I had "learned"...
I completed the first of three tasks, "1_objects.js". When I typed "node 1_objects.js" into the console I get a throw err as follows.
module.js:550find throw err;
Error: Cannot find module ' /home/treehouse/workspace/1_objects.js' at Function.Module._resolveFilename (module.js:548:15) at Function.Module._load (module.js:475:25) at Function.Module.runMin (module.js:694:10) at startup (bootstrap_node.js:204:16) at bootstrap_node.js:625:3 (arg: 45678
I went through the solution video and I had actually properly completed the task. Can anyone help me understand why I am getting this throw err and what to do about it?
Thank you!
3 Answers
Steven Parker
231,269 PointsThe reason for the main issue is that you were trying to run "node 1_objects.js" (plural), but your file is named "1_object.js" (singular).
But you'll find that the output will have "NaN"'s ("Not a Number") instead of the strings you might be expecting. When you concatenate strings using the "+" operator, you should not also use commas:
//console.log(prop, + ' :', + book[prop]); <-- causes "NaN" values
console.log(prop + ': ' + book[prop]); // should work OK without commas
Daven Hietala
8,040 PointsThank you for responding!
This snap shot shows the throw error in the console.. http://w.trhou.se/jphxu2xcy9
This snap shot shows the javascript.. http://w.trhou.se/haiy11h7o5
Daven Hietala
8,040 PointsIt did not display the console as intended.
Steven Parker
231,269 PointsOne snapshot is all that is needed, it shares the entire project.
Daven Hietala
8,040 PointsThank you for your time! This answered my questions.
Steven Parker
231,269 PointsSteven Parker
231,269 Pointsif you make a snapshot of your workspace and post the link to it here, we can take a look a the code and see the issue in action.