Note that there are some explanatory texts on larger screens.

plurals
  1. POShould I check in node_modules to git when creating a node.js app on Heroku?
    primarykey
    data
    text
    <p>I followed the basic getting started 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 node_modules should be checked in to git. When I include node_modules in git my getting started application ran correctly.</p> <p>When I followed the more advanced example at:</p> <p><a href="https://devcenter.heroku.com/articles/realtime-polyglot-app-node-ruby-mongodb-socketio" rel="noreferrer">https://devcenter.heroku.com/articles/realtime-polyglot-app-node-ruby-mongodb-socketio</a> <a href="https://github.com/mongolab/tractorpush-server" rel="noreferrer">https://github.com/mongolab/tractorpush-server</a> (source)</p> <p>It instructed me to add node_modules to .gitignore. So I removed node_modules from git, added it to .gitignore, then re-deployed. This time the deployed failed like so:</p> <pre><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 "heroku ps" confirms the crash. Ok, no problem, so I rolled back the change, add node_module back to the git repository and removed it from .gitignore. However, even after reverting, I still get the same error message on deploy but now the application is running correctly again. Running "heroku ps" tells me the application is running.</p> <p>So my question is what's the right way to do this? Include node_modules 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>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload