Error 500 when not including the node_modules folder

LAST UPDATE

It appeared that one my dependencies, not yet 1.0, changed its API between 2 versions. My local version was outdated, and when pushing to Heroku, Heroku downloaded the latest version, with the API change that crashed my app.

CONCLUSION : When using libraries not stable yet (that didn't reach 1.0), stick to a specific version.

Thank you guys for trying to help me.

=================

Using Node 0.8.latest, express 3.latest.

One of my route works perfectly locally, but gives me a 500 error when the app is deployed. The error message is very app-specific, but illogic. It's a TypeError, telling me that something (that should be defined) is undefined. To make it work, the only weird solution I found was to remove node_modules from .gitignore and tracking it under git. When pushed on heroku, no error appears and the url just works

It starts to get strange when you know that I DID NOT change any code inside of the node_modules folder. I also compared locally and "heroku"ly installed dependencies by comparing a local npm ls to the list of modules produced when pushing to heroku, since it rebuilds the dependencies because they're .gitignore'd. I see minor but inexplicable differences on a few packages noted invalid with npm ls. None of this package is in my package.json file, they're dependencies for my package in package.json. Namely, connect is 2.4.4 locally and 2.5.0 on heroku, send is 0.0.4 locally and 0.1.0 on heroku, emitter-compnonent is 0.0.1 locally and 0.0.5 on heroku. The rest is striclty identical.

The other thing to note is that the error stacktrace points a module which has identical versions on both environments and which doesn't depend on nor isn't a dependency for the modules that have different versions. So even the minor dependency differences shouldn't be the cause of the problem.

But then, I can't see where does the problem come from, and I would like to avoid tracking my node_modules files. Or should I ?

UPDATE

Here's my package.json file as per request by Hector Correa

{
  "name": "myapp",
  "version": "0.1.0",
  "dependencies": {
    "express": "3.0.x",
    "mongoose": "3.0.x",
    "superagent": "0.9.x",
    "oauth": "0.9.x",
    "querystring": "0.1.x",
    "consolidate": "~0.4.0",
    "mustache": "~0.6.0",
    "singly": "*",
    "underscore": "~1.4.1"
  },
  "devDependencies": {
    "mocha": "1.4.x",
    "supertest": "0.1.x"
  },
  "engines": {
    "node": "0.8.x",
    "npm": "1.1.x"
  }
}

Below is working example package.json in Heroku

{
    "name": "MyApp"
    , "version": "0.0.1"
    , "dependencies": {
          "express": "3.x.x"
    }
    , "devDependencies": {
        "mocha": "*"
        , "should": "*"
        , "supervisor": "*"
        , "superagent": "*"
        , "request": "*"
    }
    , "engines": {
        "node": "0.8.x"
        , "npm": "1.1.x"
    }
}