Q:

Phonegap Error + Error: Cannot find module 'q'

Trying to build phonegap app but strange error :-
user@ubuntu:~/Projects/PhoneGap/testapp$ phonegap build android
[phonegap] executing 'cordova build android'...
Running command: /home/user/Projects/PhoneGap/testapp/platforms/android/cordova/build 

module.js:338
    throw err;
          ^
Error: Cannot find module 'q'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (/home/user/Projects/PhoneGap/testapp/platforms/android/cordova/lib/spawn.js:23:15)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)

You may not have the required environment or OS to build this project

cordova -v => 5.3.3
wanted: {"node":"0.8.x || 0.10.x"} (current: {"node":"0.12.7","npm":"2.11.3"}
Please suggest something .. Thanks

A:

I was struggling with same issue and finally figure out npm install q --save helps me. 

A:

I had the same issue because my cordova android version was deprecated. Upgrade with
cordova platform update android

as described here: https://cordova.apache.org/docs/en/3.1.0/guide/platforms/android/upgrading.html

A:

This worked for me:
cordova platform remove android
cordova platform add android@7.0.0

