The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Ch 5, module.js:340 throw err;

Since starting to work with socket.io, I am getting this error below. I have been scouring the internet and I have found some fixes that didn't work. Such as clearing cache and reinstalling all the modules. I also tried installing socket.io globally. Still isn't working. I have copied the code exactly (this time!) from the book and doubled checked everything, so I assume the problem is possibly with a local setting. Any suggestions of where to look?

What strikes me as odd, is it seems to call the root directory of the app twice in the above error. -> Cannot find module '/Users/dj/Portfolio/nmarket/nmarket'
I checked all of my require statements and they all seem fine.

Ok. So, I went through the source on github for chapter 5, I replaced each file individually with the code from there. After each one I tried to run the app and got the same error. After completely replacing my app with the code from github, same result. So I then I purged my node_modules folder (rm -rf node_modules) and then ran (npm cache clear) and then (npm install) and ran my app again, same error. I am at a total loss at this point.

To debug something like this I find it easier to start with something that is working and then add small chunks of code until something breaks. So even though my solution may seem annoying I would recommend going back and starting at a working Ch4 and then adding code until something breaks and then reporting it back here if it's not obvious. It should be fairly quick if you just copy and paste code from the repository rather than typing it all in again. Going the other way and trying to debug a broken code base if you have no idea where the error might be... Could lead to hours of frustration and it's possible you still might not find the solution. If you start with something working you're guaranteed to find out what breaks it.

Yeah, that was my next plan. I was just hoping it was a simple fix. I now have nvm installed, do you know what the recommended build for this book is? I want to ensure compatibility for the rest of the book.