SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    May 2013
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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?

    module.js:340
    throw err;
    ^
    Error: Cannot find module '/Users/dj/Portfolio/nmarket/nmarket'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

  2. #2
    SitePoint Author
    Join Date
    Nov 2012
    Posts
    48
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    idjk, if you remove socket.io do things begin to work? If so could you please paste here the exact lines that cause the program to break

  3. #3
    SitePoint Member
    Join Date
    May 2013
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I am not too sure which lines cause the program to break. That's really my problem. I commented out the createSocket function where socket.io was introduced and I still get the same error.


    module.js:340
    throw err;
    ^
    Error: Cannot find module '/Users/dj/Portfolio/nmarket/nmarket'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

    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.

  4. #4
    SitePoint Member
    Join Date
    May 2013
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    SitePoint Author
    Join Date
    Nov 2012
    Posts
    48
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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.

  6. #6
    SitePoint Member
    Join Date
    May 2013
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  7. #7
    SitePoint Author
    Join Date
    Nov 2012
    Posts
    48
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It was written with 0.6.x but should be compatible with everything up to and including 0.10.x


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •