Git and sharing source code


#1

Can someone describe the strategy for sharing source code.
I have an app which I have committed to Git. The Ionic git ignore file ensures that only the code is saved to the repository, OK.

Now another developer comes along and checks out to a directory. How can they simply install all the dependencies?
I am not talking about the cordova plugins but the dependencies, the ionic-native ones I am interested in, listed in the package.json file.

Or does the new developer need to go through and add each one manually?


#2

Maybe simplest is that both of you are running nvm (or nvm-for-windows) and one version of NodeJS is exclusively for this project. You both keep the npm packages in that Node version consistent with the project’s package.json, and include changes to package.json in your changelog and commit messages.

Not sure what you mean by “manually” because npm install will install a lot of packages at once if it reads a package.json. So maybe the real-but-snarky answer to your question is “Learn more about npm.” So yeah. Spend a couple days learning a bit about Node and npm, and your life will be better!


#3

Thanks for the response Aaron.

Yeah it was the npm install that I was missing.
But after that I still needed to install each native plugin from the CLI with npm. It is this that is not covered by npm install which I thought it would be.


#4

Did you try ionic platform add ___ first? Adding platforms installs some cordova plugins automatically.


#5

You can try Yarn which is an advanced version of npm. It will also lock the versions of the node packages so that all developers will have exact same library version as checked in git.

You can use git hooks for automatically running yarn (or npm install) whenever package.json updates …

For managing Codova plugins you can run ‘cordova save’ which will save installed plugin versions in config.xml
Also there is a command ‘ionic state’ … not sure though if it still works


#6

In the end I did

npm install

Then install all native plugins with

ionic plugin add --save [pluginName]
npm install --save @ionic-native/[pluginName] 

And that worked for me.