title: Heroku Build Failed: "node_modules checked into source control"
body: <p>I am deploying a site built upon MEAN stack on Heroku. While troubleshooting an issue I removed <strong>node_modules/</strong> from my .gitignore file and ever since my app has been getting "Build failed" errors.</p>
  
  <p>I readded node_modules/ to the file, but it seems the damage has been done as builds still fail.</p>
  
  <p>One of the possible problems that is suggested in the log is:
  "- node_modules checked into source control"</p>
  
  <p>How do I go about undoing what I did?</p>
  
  <pre><code> -----&gt; Deleting 1 files matching .slugignore patterns.
   -----&gt; Using set buildpack heroku/nodejs
   -----&gt; Node.js app detected
   -----&gt; Creating runtime environment
  
     NPM_CONFIG_LOGLEVEL=error
     NPM_CONFIG_PRODUCTION=true
     NODE_ENV=production
     NODE_MODULES_CACHE=true
   -----&gt; Installing binaries
     engines.node (package.json):  0.10.x
     engines.npm (package.json):   2.x.x
  
     Resolving node version 0.10.x via semver.io...
     Downloading and installing node 0.10.41...
     Resolving npm version 2.x.x via semver.io...
     Downloading and installing npm 2.14.15 (replacing version 1.4.29)...
     npm WARN deprecated This version of npm lacks support for important features,
     npm WARN deprecated such as scoped packages, offered by the primary npm
     npm WARN deprecated registry. Consider upgrading to at least npm@2, if not the
     npm WARN deprecated latest stable version. To upgrade to npm@2, run:
     npm WARN deprecated
     npm WARN deprecated   npm -g install npm@latest-2
     npm WARN deprecated
     npm WARN deprecated To upgrade to the latest stable version, run:
     npm WARN deprecated
     npm WARN deprecated   npm -g install npm@latest
     npm WARN deprecated
     npm WARN deprecated (Depending on how Node.js was installed on your system, you
     npm WARN deprecated may need to prefix the preceding commands with `sudo`, or if
     npm WARN deprecated on Windows, run them from an Administrator prompt.)
     npm WARN deprecated
     npm WARN deprecated If you're running the version of npm bundled with
     npm WARN deprecated Node.js 0.10 LTS, be aware that the next version of 0.10 LTS
     npm WARN deprecated will be bundled with a version of npm@2, which has some small
     npm WARN deprecated backwards-incompatible changes made to `npm run-script` and
     npm WARN deprecated semver behavior.
   -----&gt; Restoring cache
     Loading 2 from cacheDirectories (default):
     - node_modules (exists - skipping)
     - bower_components (not cached - skipping)
   -----&gt; Building dependencies
     Prebuild detected (node_modules already exists)
     Rebuilding any native modules
  
     &gt; bson@0.2.22 install /tmp/build_###########/node_modules/connect-mongo/node_modules/bson
     &gt; (node-gyp rebuild 2&gt; builderror.log) || (exit 0)
  
     make: Entering directory `/tmp/build_###########/node_modules/connect-mongo/node_modules/bson/build'
     CXX(target) Release/obj.target/bson/ext/bson.o
     SOLINK_MODULE(target) Release/obj.target/bson.node
     COPY Release/bson.node
     make: Leaving directory `/tmp/build_###########/node_modules/connect-mongo/node_modules/bson/build'
  
     &gt; bson@0.2.22 install /tmp/build_###########/node_modules/connect-mongo/node_modules/bson
     &gt; (node-gyp rebuild 2&gt; builderror.log) || (exit 0)
  
     make: Entering directory `/tmp/build_###########/node_modules/connect-mongo/node_modules/bson/build'
     CXX(target) Release/obj.target/bson/ext/bson.o
     SOLINK_MODULE(target) Release/obj.target/bson.node
     COPY Release/bson.node
     make: Leaving directory `/tmp/build_###########/node_modules/connect-mongo/node_modules/bson/build'
  
     &gt; bson@0.2.22 install /tmp/build_###########/node_modules/mongoose/node_modules/mongodb/node_modules/bson
     &gt; (node-gyp rebuild 2&gt; builderror.log) || (exit 0)
  
     make: Entering directory `/tmp/build_###########/node_modules/mongoose/node_modules/mongodb/node_modules/bson/build'
     CXX(target) Release/obj.target/bson/ext/bson.o
     SOLINK_MODULE(target) Release/obj.target/bson.node
     COPY Release/bson.node
     make: Leaving directory `/tmp/build_###########/node_modules/mongoose/node_modules/mongodb/node_modules/bson/build'
  
     &gt; phantomjs@1.9.19 install /tmp/build_###########/node_modules/phantomjs
     &gt; node install.js
  
     PhantomJS not found on PATH
     Downloading https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
     Saving to /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2
     Receiving...
  
     Received 12854K total.
     Extracting tar contents (via spawned process)
     Removing /tmp/build_###########/node_modules/phantomjs/lib/phantom
     Copying extracted folder /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-1450118671217/phantomjs-1.9.8-linux-x86_64 -&gt; /tmp/build_###########/node_modules/phantomjs/lib/phantom
     Writing location.js file
     Done. Phantomjs binary available at /tmp/build_###########/node_modules/phantomjs/lib/phantom/bin/phantomjs
  
     &gt; kerberos@0.0.11 install /tmp/build_###########/node_modules/kerberos
     &gt; (node-gyp rebuild 2&gt; builderror.log) || (exit 0)
  
     make: Entering directory `/tmp/build_###########/node_modules/kerberos/build'
     CXX(target) Release/obj.target/kerberos/lib/kerberos.o
     CXX(target) Release/obj.target/kerberos/lib/worker.o
     CC(target) Release/obj.target/kerberos/lib/kerberosgss.o
     CC(target) Release/obj.target/kerberos/lib/base64.o
     CXX(target) Release/obj.target/kerberos/lib/kerberos_context.o
     SOLINK_MODULE(target) Release/obj.target/kerberos.node
     COPY Release/kerberos.node
     make: Leaving directory `/tmp/build_###########/node_modules/kerberos/build'
  
     &gt; ws@0.4.32 install /tmp/build_###########/node_modules/ws
     &gt; (node-gyp rebuild 2&gt; builderror.log) || (exit 0)
  
     make: Entering directory `/tmp/build_###########/node_modules/ws/build'
     CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
     SOLINK_MODULE(target) Release/obj.target/bufferutil.node
     COPY Release/bufferutil.node
     CXX(target) Release/obj.target/validation/src/validation.o
     SOLINK_MODULE(target) Release/obj.target/validation.node
     COPY Release/validation.node
     make: Leaving directory `/tmp/build_###########/node_modules/ws/build'
  
     &gt; v8-profiler@5.2.12 preinstall /tmp/build_###########/node_modules/v8-profiler
     &gt;
  
  
     &gt; v8-profiler@5.2.12 install /tmp/build_###########/node_modules/v8-profiler
     &gt; node-pre-gyp install --fallback-to-build
  
     sh: 1: node-pre-gyp: Permission denied
  
     npm ERR! Linux 3.13.0-71-generic
     npm ERR! argv "node" "/tmp/build_###########/.heroku/node/bin/npm" "rebuild"
     npm ERR! node v0.10.41
     npm ERR! npm  v2.14.15
     npm ERR! code ELIFECYCLE
     npm ERR! v8-profiler@5.2.12 install: `node-pre-gyp install --fallback-to-build`
     npm ERR! Exit status 126
     npm ERR!
     npm ERR! Failed at the v8-profiler@5.2.12 install script 'node-pre-gyp install --fallback-to-build'.
     npm ERR! This is most likely a problem with the v8-profiler package,
     npm ERR! not with npm itself.
     npm ERR! Tell the author that this fails on your system:
     npm ERR!     node-pre-gyp install --fallback-to-build
     npm ERR! You can get their info via:
     npm ERR!     npm owner ls v8-profiler
     npm ERR! There is likely additional logging output above.
  
     npm ERR! Please include the following file with any support request:
     npm ERR!     /tmp/build_###########/npm-debug.log
   -----&gt; Build failed
  
     We're sorry this build is failing! You can troubleshoot common issues here:
     https://devcenter.heroku.com/articles/troubleshooting-node-deploys
  
     Some possible problems:
  
     - node_modules checked into source control
     https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
  
     Love,
     Heroku
  
    !     Push rejected, failed to compile Node.js app
  </code></pre>