How to share ionic project with native code in git

I have added an android background service (java) in platforms/android/
Now, how do I share this over git?
My current .gitignore file in the root is as follows.

#Specifies intentionally untracked files to ignore when using Git
#http://git-scm.com/docs/gitignore
node_modules/
plugins/
nbproject/

The .gitignore in platforms/android/ is as follows:

# Non-project-specific build files:
build.xml
local.properties
/gradlew
/gradlew.bat
/gradle
# Ant builds
ant-build/
ant-gen/
# Eclipse builds
gen
out
# Gradle builds
/build

I tried committing everything and then cloned it in a different directory to test it.
I ran the following commands

npm install
npm update
bower update

also with -g and sudo and what not,
basically all the commands I could so that it would work,
but when running

ionic build

it always throws this error

module.js:340
     throw err;
           ^
 Error: Cannot find module 'q'
     at Function.Module._resolveFilename (module.js:338:15)
     at Function.Module._load (module.js:280:25)
     at Module.require (module.js:364:17)
     at require (module.js:380:17)
     at Object.<anonymous> (/home/username/Projects/appname/platforms/android/cordova/lib/exec.js:23:15)
     at Module._compile (module.js:456:26)
     at Object.Module._extensions..js (module.js:474:10)
     at Module.load (module.js:356:32)
     at Function.Module._load (module.js:312:12)
     at Module.require (module.js:364:17)

I tried installing q manually, it installed, yet this error is thrown.
How do I get this to work?