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