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 trialbabyoscar
12,930 PointsI cannot debug because it throws an error
When I try to open debug mode, it starts, and then instantly throws:
Debugger attached.
Waiting for the debugger to disconnect...
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'http-errors'
How can I fix this?
2 Answers
Robert Manolis
Treehouse Guest TeacherHi babyoscar, it looks like you need to install the http-errors module. Kill the app and run npm i http-errors
, then start the app again.
James Fleming
Full Stack JavaScript Techdegree Graduate 15,848 PointsSo I was getting all of these same errors. Every time I would install a module, it would come back and say "cannot find module 'pug' or whatever the module was that it couldn't find. I kept running "npm i " followed by the module it couldn't find and eventually, it worked and the page loaded on the browser. Strange that isn't mentioned in the video but it did work. Hopefully this helps!
babyoscar
12,930 PointsYes, I did that, but it's not creating a launch.json
file. I've moved on from this course, but thanks!
babyoscar
12,930 Pointsbabyoscar
12,930 PointsOkay, it works for the http-errors, but why do I have to install each module seperately? I ran "npm install" but after I ran what you said, it said cannot find module express. I did npm i express, then it said cannot find module cookie-parser. Why is that?
Robert Manolis
Treehouse Guest TeacherRobert Manolis
Treehouse Guest TeacherHey babyoscar , running
npm i
will install any dependencies that are already listed in your package.json file. If you have dependencies that are being imported in your project files but aren't listed in the package.json file and haven't been installed, then they will need to be installed individually.babyoscar
12,930 Pointsbabyoscar
12,930 PointsMy package.json looks like:
I ran
npm i
but it still says Error: cannot find module 'cookie-parser' even though its in my package.json file. Why is that?babyoscar
12,930 Pointsbabyoscar
12,930 PointsOkay, I just installed each one individually, but when I click Run --> Start Debugging --> Node.js (Legacy) , or click the bug with the play button --> run and debug --> Node.js (Legacy), it doesn't create a launch.json file, how do I fix that?
Robert Manolis
Treehouse Guest TeacherRobert Manolis
Treehouse Guest TeacherNot sure, babyoscar. I don't use the debugger much, and haven't messed with the launch.json file. Try Googling on that, or creating a new post in the community. And make sure your Node and npm are updated to the latest stable version.
babyoscar
12,930 Pointsbabyoscar
12,930 PointsOkay, thanks.