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 Introducing the Practice

Daven Hietala
Daven Hietala
8,040 Points

Practice 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!

Steven Parker
Steven Parker
229,644 Points

if 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.

3 Answers

Steven Parker
Steven Parker
229,644 Points

The 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
Daven Hietala
8,040 Points

Thank 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
Daven Hietala
8,040 Points

It did not display the console as intended.

Steven Parker
Steven Parker
229,644 Points

One snapshot is all that is needed, it shares the entire project.

Daven Hietala
Daven Hietala
8,040 Points

Thank you for your time! This answered my questions.