title: Should I check in folder "node_modules" to Git when creating a Node.js app on Heroku?
body: <p>I followed the basic <em>getting started</em> instructions for Node.js on Heroku here:</p>
  <p><a href="https://devcenter.heroku.com/categories/nodejs" rel="noreferrer">https://devcenter.heroku.com/categories/nodejs</a></p>
  <p>These instruction don't tell you to create a .gitignore node_modules, and therefore imply that folder <em>node_modules</em> should be checked in to Git.  When I included <em>node_modules</em> in Git repository, my getting started application ran correctly.</p>
  <p>When I followed the more advanced example at:</p>
  <ul>
  <li><em><a href="https://devcenter.heroku.com/articles/realtime-polyglot-app-node-ruby-mongodb-socketio" rel="noreferrer">Building a Real-time, Polyglot Application with Node.js, Ruby, MongoDB and Socket.IO</a></em></li>
  <li><a href="https://github.com/mongolab/tractorpush-server" rel="noreferrer">https://github.com/mongolab/tractorpush-server</a>  (source)</li>
  </ul>
  <p>It instructed me to add folder <em>node_modules</em> to file <em>.gitignore</em>. So I removed folder <em>node_modules</em> from Git, added it to file <em>.gitignore</em>, and then redeployed. This time the deployed failed like so:</p>
  <pre class="lang-none prettyprint-override"><code>-----&gt; Heroku receiving push
  -----&gt; Node.js app detected
  -----&gt; Resolving engine versions
         Using Node.js version: 0.8.2
         Using npm version: 1.0.106
  -----&gt; Fetching Node.js binaries
  -----&gt; Vendoring node into slug
  -----&gt; Installing dependencies with npm
         Error: npm doesn't work with node v0.8.2
         Required: node@0.4 || 0.5 || 0.6
             at /tmp/node-npm-5iGk/bin/npm-cli.js:57:23
             at Object.&lt;anonymous&gt; (/tmp/node-npm-5iGk/bin/npm-cli.js:77:3)
             at Module._compile (module.js:449:26)
             at Object.Module._extensions..js (module.js:467:10)
             at Module.load (module.js:356:32)
             at Function.Module._load (module.js:312:12)
             at Module.require (module.js:362:17)
             at require (module.js:378:17)
             at Object.&lt;anonymous&gt; (/tmp/node-npm-5iGk/cli.js:2:1)
             at Module._compile (module.js:449:26)
         Error: npm doesn't work with node v0.8.2
         Required: node@0.4 || 0.5 || 0.6
             at /tmp/node-npm-5iGk/bin/npm-cli.js:57:23
             at Object.&lt;anonymous&gt; (/tmp/node-npm-5iGk/bin/npm-cli.js:77:3)
             at Module._compile (module.js:449:26)
             at Object.Module._extensions..js (module.js:467:10)
             at Module.load (module.js:356:32)
             at Function.Module._load (module.js:312:12)
             at Module.require (module.js:362:17)
             at require (module.js:378:17)
             at Object.&lt;anonymous&gt; (/tmp/node-npm-5iGk/cli.js:2:1)
             at Module._compile (module.js:449:26)
         Dependencies installed
  -----&gt; Discovering process types
         Procfile declares types -&gt; mongod, redis, web
  -----&gt; Compiled slug size is 5.0MB
  -----&gt; Launching... done, v9
  </code></pre>
  <p>Running &quot;heroku ps&quot; confirms the crash. OK, no problem, so I rolled back the change, added folder <em>node_module</em> back to the Git repository and removed it from file <em>.gitignore</em>. However, even after reverting, I still get the same error message on deploy, but now the application is running correctly again. Running &quot;heroku ps&quot; tells me the application is running.</p>
  <p>What's the right way to do this? Include folder <em>node_modules</em> or not?  And why would I still be getting the error message when I rollback? My guess is the Git repository is in a bad state on the Heroku side.</p>