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 Asynchronous Programming with JavaScript Understanding Promises Reject a Promise and Handle Errors

terminal error

When I run the code in the terminal it gives me a bunch of error node promises-breakfast.js

Error: Cannot find module '/home/treehouse/workspace/promises-breakfast.js'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3

Hi, I came across the same problem; it seems that the terminal can't find the location of "promises-breakfast.js", hence the error. I solved this by working on my text editor rather than on the Workspace. Create a "promises-breakfast.js" file on your compter, then execute the node command on the built in terminal (or in any other bash terminal, for that matter), just like Guil does in the tutorial. Make sure that, before running the node command, you're located in the directory in which your JS file is saved, otherwise it won't find it and give you the same error. Hope that helped!

1 Answer

Courtney Wilson
Courtney Wilson
8,031 Points

You can run it in Workspaces by specifying the location of the file, which is in the js folder:

node js/promises-breakfast.js