I want to understand better the relationship between the node_modules that are part of my Node project on my local machine and those that are part of my app that resides on Heroku.
When I'm building and testing a project locally (on my machine, using my localhost), I need to download various Node modules (e.g., mongodb, mongoose, util, express, and others). When I've tested my app locally, I want to push it up to the server. When I do the push, the node_modules folder also gets pushed up.
So what happens if I've already installed MongoDB (via the Heroku MongoLab Add-On) and Mongoose on Heroku through my account's/app's dashboard, and then I push my project up, which has a node_modules folder (containing mongodb)? Does my local mongodb node_module overwrite the module that was created using the MongoLab shell on Heroku? Or does Heroku ignore my push and preserve its version?
And what about the databases? Presumably the databases (local and Heroku) are completely isolated from each other, so there's no possibility of any conflict there. So I'm more interested to know what happens with the contents of the node_modules.
I know that you can set .gitgnore to ignore various things (like a node_modules folder), but then i lose the other modules my app needs, and it doesn't run. And I know you can selectively exclude certain folders. The question is whether I need to add any entries to my .gitignore to exclude things like MongoDB (and/or Mongoose).
Thanks in anticipation of a clarification.
You should be putting adding your module dependencies in package.json and including node_modules/ in your .gitignore.
With the dependencies listed in package.json, Heroku will download those packages every time you do a push and you can easily keep your dev environment in sync with your deployment environment.
The local MongoDB is independent of your Heroku MongoDB, however, if you want to setup your dev environment to access the Heroku MongoDB you can do so by pulling the environment variables from Heroku and putting them in `.env' like this:
heroku config -s > .env
Then you can launch your app with foreman and it will load the environment variables in your .env
foreman start
Then your dev app will connect to the same MongoDB instance that your Heroku app does. This is useful if you keep a staging app on Heroku.