Question

Hoping to get some guidance regarding version control of Angular2 project.

Recently i started coding in Angular2, used angular-cli to create a brand new project and go through standard 5 minute setup as per angular.io site.

Now to the version control dilemma i seem to face. I currently ignore node_modules folder and store everything else in git. However when the project is cloned elsewhere, you need to run npm install to get all the node modules as required by project.

This results in a large number of unmet dependencies as npm v5 doesn't get peer dependencies. As such creates a lot of inefficiencies as you have to identify what is missing then install individually.

My question in 2 parts essentially:

  1. What should be ignored when storing the angluar-cli created project in git
  2. What should the proper process be after you clone the project to get the project working with all the required packages

Hoping for some guidance as to what works effectively to avoid these headaches in future.

Was it helpful?

Solution

As always it depends a lot on you and how you want to do things, but here's my recommendation: Only include the source files used to build the project. This means that you ignore everything that isn't your code, unless there's good reason to include it.

For how to get the code up and running for a new developer this typically depends on the size of the project. For a small project a README with installation commands is enough - As @jonrsharpe commented package installers should solve your dependencies, else you're doing something quite wrong somewhere else or perhaps have modules with conflicting dependencies.

There aren't strict guidelines but the bigger the project is the less a developer will know about how to set up a potential environment, so as your project matures automation of processes becomes key, this is also nice because it's self-documenting the steps taken to produce the final product.

Don't concern yourself too much with that, but I have a rule of thumb which I attempt to follow that you should be able to get a project up and running in one command. Be it by scripts or doing something more advanced like setting up a provisioned VM through Vagrant.

Licensed under: CC-BY-SA with attribution
scroll top